Images Not Appearing on Your Joomla Website?

Quite often, we have customers coming to us and telling us that they have some images that are not appearing on their Joomla website. After investigation, it all comes down (mainly) to three reasons:

  1. Joomla SEF or an equivalent URL rewrite extension
  2. The short_open_tag directive in php.ini
  3. The asp_tag directive in php.ini

Let us discuss each one of the above.

Joomla SEF causing images not to display

As a rule, the URL rewriting on the page must happen after the content is generated on the website, and before the cache. This means that under Extensions“Manage Plugins”, you need to make sure that the order of the Joomla SEF plugin is after all the content plugins, but before the Joomla Cache plugin.

If the URL rewriting happens before that stage, then some of the URLs generated may be broken or may not be rewritten. However, the Joomla SEF is sometimes too smart even for its own good, as it tries to rewrite/manipulate URLs that are already rewritten or that do not need to be rewritten, including URLs of images. So if this thing happens, you will have broken images on your website. The solution to this problem is to search for the plugin that generates the affected content (usually it’s not a core plugin) and make sure that its ordered to be executed after the Joomla SEF runs. You might be wondering, isn’t this against the rule that we talked about earlier? It is, but then again, this is programming, and there are many, many exceptions to every rule.

How do you know instantly that the problem is related to Joomla SEF plugin?

In order to know in less than 1 minute whether the Joomla SEF plugin is the culprit, disable it, and then check if the images are now appearing, if they are, then for sure the reason for them not appearing is the URL rewriting.

short_open_tag PHP directive is set to off – but it is used

Let’s say you move your Joomla website to another (new?) server, and then you start testing it. Everything works perfectly, except that some of the images are no longer displaying. You try everything, you even disable the Joomla SEF plugin and your turn off URL rewriting, but yet the images are still not appearing. You’re lost. You then decide to check the code of your HTML page, to see how the images are linked to, and to your surprise, here’s what you see:

<img src="<? echo(YOUR_DOMAIN_URL.'/images/your_missing_image.jpg'); ?>">

You think, odd… This looks like it’s still written in PHP, why is that? Well, the reason is that the above was not parsed by the PHP parser is that it’s using something called short open tags, whereby the programmer uses <? to open the PHP tags (where he writes PHP code), instead of using the <?php . There are four ways to fix this problem:

  1. Open your php.ini file, search for the directive short_open_tag, and change its value to on instead of off.
  2. Create a local php.ini (which is a copy of the global php.ini), put it in the root directory of your website, and change the value of the short_open_tag directive to on.
  3. Open your index.php file in the root directory of your Joomla website and type the following (in the first line, before any code starts, but after <?php ): ini_set( "short_open_tag", 1 );
  4. Locate the file(s) that contains this code <? and change it with <?php

asp_tags PHP directive is set to off – but it is used

There are programmers that have ASP background (ASP is a web scripting language developed by Microsoft) and they’re used to the ASP tags and so they write code like the following line:

<%=YOUR_DOMAIN_URL.'/images/your_missing_image.jpg'%>.

The problem though with the above line that it won’t work if the asp_tags directive is not set to on. You have 3 ways to fix this problem:

  1. Open your php.ini file, search for the directive asp_tags, and change its value to on instead of off.
  2. Create a local php.ini, put it in the root directory of your website, and change the value of the asp_tags directive to on.
  3. Locate the file(s) that contains this code <% and change it with <?php

There are, of course, many other reasons for the images to disappear or not appear in the first place on your website, including:

  • Wrong PHP script used to display the images
  • Path to the images has changed
  • Read permissions not given on the images directory

If you need any help with your Joomla website not displaying the images, then feel free to contact us. We’re always friendly, our fees are reasonable, and we’re always there!

10 Responses to “Images Not Appearing on Your Joomla Website?”
  1. Comment by Himanshu Nagpal — March 22, 2014 @ 5:39 am

    Great Article, I tried everything like htaccess editing, few template editing but that didn’t fix the problem. Reordering of SEF plugin which I could never figure out on my own has solved my problem. Thanks a lot for sharing great and nice tip!

  2. Comment by Albert Darks — November 23, 2014 @ 5:18 pm

    This is really great! I tried everything before but nothing helped. Thank you very much!

  3. Comment by Al — December 18, 2014 @ 11:35 am

    Nice article. This fixed my problem.

    Perhaps you could write an article about the best order plugins should be in to make a site run faster and work well.

    When I look at the ordering of plugins, there are so many that I don’t know what to do with them, or what they do…and to be honest, I don’t really know how to re order things!

    A guide for joomla dummies like me would be perfect.

    But getting back to your article. Thanks. It was a great help.

  4. Comment by Matt — April 19, 2015 @ 11:07 pm

    I am having a problem with the images on my site disappearing about 15 seconds after they load.

    I don’t have the line shown above in my php.ini file.

    I tried reordering the plugins and no go. Do you do any consulting on fixing this problem?

  5. Comment by Fadi — April 21, 2015 @ 8:31 am

    Hi Matt,

    Typically this is a problem that has to do with some JavaScript code trying to alter the img tags. Yes – we can help. Please contact us.

  6. Comment by Shumisha — October 3, 2015 @ 4:24 am

    Hi

    The main reason for images not appearing when Joomla SEF is enabled has nothing to do with Joomla SEF. The main reason (100% in my almost 10 years of Joomla) is extensions creating links with relative URLs.

    Relative URLs are those that starts directly with the path (href=”path/to/my/image.jpg”) instead of being properly started either with a / (href=”/path/to/my/image.jpg”) or with the site domain (href=”https://mysite.com/path/to/my/image.jpg”).

    If you use a relative URL in your links, you will get a 404 for that link on all pages except the home page.

    The only proper solution is to fix the initial link. Note that when using WYSIWYG editors such as TinyMCE or JCE, images links are properly processed by the editor and Joomla to be correctly prepended with a /.

    You can confirm this behavior by using Firebug or Chrome developer tools and check that the images that won’t show are generating a 404 and the link to them is incorrect.

    Also not that the same is actually true for CSS and javascript files as well.

    Rgds

  7. Comment by Fadi — October 4, 2015 @ 3:46 am

    Hi Shumisha,

    Thanks for your feedback. We are seeing this problem much more rarely than before (this is a very old post) since now most extensions and editors handle images properly (this post was written nearly 4 years ago).

  8. Comment by Jupiter — May 29, 2017 @ 12:09 pm

    You saved my brain. I was fighting with this for one month.

  9. Comment by Fred — November 2, 2017 @ 2:55 pm

    Hi,

    There is one more reason where some images do not appear after migrating a Joomla site: it is if you are migrating from Windows to Linux. Spent half a day to finally remember that in Linux names are case sensitive. For an experienced coder it is basics but for a simple content provider it might take a while to realize, perhaps add it to your article

  10. Comment by Fadi — December 5, 2017 @ 6:33 pm

    Hi Fred,

    Thanks for sharing! Yes, names are case sensitive in Linux (which, IMHO, the right thing to do). In order to avoid any problems in naming, then it’s a good idea to only use lowercase alphanumeric characters (and dashes) in the names of images (for example, image-octopus-1.jpg). This will save a lot of headaches.

Leave a comment