From 3c86b7ebf3316c3566a7f6fed683a484036d1c3b Mon Sep 17 00:00:00 2001
From: Anika Henke <anika@selfthinker.org>
Date: Sun, 8 Apr 2012 17:35:06 +0100
Subject: [PATCH] removed align attribute from images and inserted them only in
 the feed (FS#1351)

can someone with better regex skills please revise this?
---
 feed.php             | 4 ++++
 inc/parser/xhtml.php | 4 ----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/feed.php b/feed.php
index 98d5ef2e8..dafbb3c07 100644
--- a/feed.php
+++ b/feed.php
@@ -324,6 +324,10 @@ function rss_buildItems(&$rss,&$data,$opt){
                         // no TOC in feeds
                         $content = preg_replace('/(<!-- TOC START -->).*(<!-- TOC END -->)/s','',$content);
 
+                        // add alignment for images
+                        $content = preg_replace('/class="medialeft"/s', 'class="medialeft" align="left"', $content);
+                        $content = preg_replace('/class="mediaright"/s', 'class="mediaright" align="right"', $content);
+
                         // make URLs work when canonical is not set, regexp instead of rerendering!
                         if(!$conf['canonical']){
                             $base = preg_quote(DOKU_REL,'/');
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 157d0d76a..4514a18a4 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -1075,10 +1075,6 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
             $ret .= '<img src="'.ml($src,array('w'=>$width,'h'=>$height,'cache'=>$cache)).'"';
             $ret .= ' class="media'.$align.'"';
 
-            // make left/right alignment for no-CSS view work (feeds)
-            if($align == 'right') $ret .= ' align="right"';
-            if($align == 'left')  $ret .= ' align="left"';
-
             if ($title) {
                 $ret .= ' title="' . $title . '"';
                 $ret .= ' alt="'   . $title .'"';
-- 
GitLab