Joomla version: 1.5.20
Mobile Joomla! version: 0.9.7
PHP version: 5.2.8
A number of images were broken on the mobile version of the site I was testing. I narrowed it down to images that are being resized. The URL after resize always started off with slashes (//) instead of one:
<img [snip] src="//images/stories/Resized/imagename_240x253.jpg" />
It happens regardless of whether the original image URL is relative or absolute. The culprit is in /administrator/components/com_mobilejoomla/imagerescaler.class.php line ~180:
$dest_imageuri = $base_rel.implode('/', explode(DS, substr($dest_imagepath, strlen(JPATH_SITE))));
If the image's path ($dest_imagepath) is:
/home/sitepath/public_html/images/stories/Resized/imagename_240x253.jpg
Then the substr() will shorten it to
/images/stories/Resized/imagename_240x253.jpg
The explode() will result in an array like this:
Array (
[0] =>
[1] => images
[2] => stories
[3] => Resized
[4] => imagename_240x253.jpg
)
And finally the implode() will result in this:
//images/stories/Resized/imagename_240x253.jpg
Which is what is returned as the URI path ($dest_imageuri).
Is this a known issue? I would think something like this would have been picked up and fixed a during initial testing, considering it breaks all resized images...
Either way, my solution was to simply check for double slashes and remove one them if found:
$dest_imageuri = $base_rel.implode('/', explode(DS, substr($dest_imagepath, strlen(JPATH_SITE))));
$dest_imageuri = str_replace("//", "/", $dest_imageuri);