?
avatar alwarren
alwarren
4 Aug 2012

When calling JJHTML::image() with $relative set to true, a bad image link is created in administrator when an image file exists only in JPATH_THEMES . "/$template/$folder/system/$file".

Discussion and test file at http://forum.joomla.org/viewtopic.php?f=579&t=734663

Cause:
See the statements at about line 417 of /libraries/joomla/hmtl/html.php

// Try to deal with system files in the template folder
elseif (file_exists(JPATH_THEMES . "/$template/$folder/system/$file"))
{
    $includes[] = JURI::root(true) . "/templates/$template/$folder/system/$file";
    break;
}

The file is detected in /$template/$folder/system/$file but the link builds as webroot/$template/$folder/system/$file. In administrator, the link should be built as webroot/administrator/$template/$folder/system/$file instead.

Solution:
Change

    $includes[] = JURI::root(true) . "/templates/$template/$folder/system/$file";

To:

    $includes[] = JURI::root(true) . ($app->isAdmin() ? '/administrator' : '') . "/templates/$template/$folder/system/$file";

To be honest, I don't know how this scenario would exist unless someone moved an image into /templates/$template/$folder/system. But, I thought I'd post this in case someone ran across it or the developers wanted to do a fix.

avatar alwarren alwarren - open - 4 Aug 2012
avatar elinw
elinw - comment - 25 Aug 2012

This is an issue in the platform. Would you make a pull request for the change and explain why you think it is necessary in the platform repository?

avatar zero-24 zero-24 - close - 28 Dec 2012
avatar mbabker mbabker - close - 28 Dec 2012
avatar zero-24 zero-24 - change - 7 Jul 2015
Labels Added: ?
Build staging

Add a Comment

Login with GitHub to post a comment