Make sure the System - SEF
plugin is published. This plugin contains the following code, which should be adding the correct URL path to images before the page is rendered:
// Replace src links.
$base = JUri::base(true) . '/';
$buffer = $this->app->getBody();
// Replace index.php URI by SEF URI.
if (strpos($buffer, 'href="index.php?') !== false)
{
preg_match_all('#href="index.php\?([^"]+)"#m', $buffer, $matches);
foreach ($matches[1] as $urlQueryString)
{
$buffer = str_replace('href="index.php?' . $urlQueryString . '"', 'href="' . JRoute::_('index.php?' . $urlQueryString) . '"', $buffer);
}
$this->checkBuffer($buffer);
}
// Check for all unknown protocals (a protocol must contain at least one alpahnumeric character followed by a ":").
$protocols = '[a-zA-Z0-9\-]+:';
$attributes = array('href=', 'src=', 'poster=');
foreach ($attributes as $attribute)
{
if (strpos($buffer, $attribute) !== false)
{
$regex = '#\s+' . $attribute . '"(?!/|' . $protocols . '|\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, ' ' . $attribute . '"' . $base . '$1"', $buffer);
$this->checkBuffer($buffer);
}
}
In this case, the true
in the JUri::base(true)
means that it is the path that is being generated rather than the full URL. You could get an absolute link by removing the "true", but note that in practise you should never edit core files, so this would require a new plug-in to be done properly. Also, the base path and absolute URL should both work so even if this fixed the issue, the actual cause of your problem is most likely elsewhere.
Your example /images/flags/en.png
actually makes it look like this plugin is working correctly, since that /
at the beginning (assuming your site is in the root of your domain) means it will be loading the image from the root rather than relative to the page you are on, as it should. In your database, the image will most likely be saved at images/flags/en.png
.
Does this image actually exist at http://www.yourdomain.com/images/flags/en.png ? If not, where does the image load from when SEF is turned off?