[TYPO3-core] RFC: Fix for supporting style url() path transformation / templavoila bug #1669

Robert Lemke robert at typo3.org
Wed Nov 2 14:15:55 CET 2005


Hi Kasper,

while mapping a page template, paths which are inside a 
style="background-image: url(mypath/image.jpg)" are not translated to the 
relative site path.

In t3lib_parsehtml you have these lines which should translate it:

foreach($parts as $k => $v)	{
   if ($k%2)	{
      $parts[$k] = eregi_replace('(url[[:space:]]*\([[:space:]]*["\']?)
([^"\')]*)(["\']?[[:space:]]*\))','\1'.$prefix.'\2'.$suffix.'\3',$parts[$k]);
   }
}

However, with the page templates I tested, $parts has only one item which is 
$parts[0], so $k%2 is never true.

I removed the if($k%2), then the URLs in style sections were correct an I 
didn't discover any other bad side effects. Do you know why you put in the if 
($k%2) there?

Cheers,
robert

-- 
Robert Lemke
TYPO3 Association - Research & Development
Member of the board
http://association.typo3.org
-------------- next part --------------
Index: class.t3lib_parsehtml.php
===================================================================
RCS file: /cvsroot/typo3/TYPO3core/t3lib/class.t3lib_parsehtml.php,v
retrieving revision 1.24
diff -u -r1.24 class.t3lib_parsehtml.php
--- class.t3lib_parsehtml.php	19 Jun 2005 22:48:47 -0000	1.24
+++ class.t3lib_parsehtml.php	2 Nov 2005 13:08:28 -0000
@@ -880,9 +880,7 @@
 		if (strlen($prefix))	{
 			$parts = $this->splitIntoBlock('style',$content);
 			foreach($parts as $k => $v)	{
-				if ($k%2)	{
-					$parts[$k] = eregi_replace('(url[[:space:]]*\([[:space:]]*["\']?)([^"\')]*)(["\']?[[:space:]]*\))','\1'.$prefix.'\2'.$suffix.'\3',$parts[$k]);
-				}
+				$parts[$k] = eregi_replace('(url[[:space:]]*\([[:space:]]*["\']?)([^"\')]*)(["\']?[[:space:]]*\))','\1'.$prefix.'\2'.$suffix.'\3',$parts[$k]);
 			}
 			$content = implode('',$parts);
 		}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20051102/c011581a/attachment.pgp 


More information about the TYPO3-team-core mailing list