Images not loading initial "/" removed
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
- Jeyjoo
- Joomla! Explorer
- Posts: 344
- Joined: Tue Jul 19, 2011 8:56 am
- Location: Monaco
- Contact:
Images not loading initial "/" removed
Hi,
We have a problemon a website using relative images within articles that I have never come across.
The first time a webpage is loaded, images load fine. After 1 or 2 page refreshes, images stop showing. Digging deeper, we noticed the problem is with compilation of relative image url.
Example
Intially the image url in the browser code is:
<img src="/images/logo.png">
After refreshing the page, the image code loses the initial "/", becoming
<img src="images/logo.png">
This causes no problems when in root folder, but when in a subfolder, such as www.oursite.com/blog/pageurl, the relative image url breaks without the trailing slash.
Anyone ideas?
Thanks
We have a problemon a website using relative images within articles that I have never come across.
The first time a webpage is loaded, images load fine. After 1 or 2 page refreshes, images stop showing. Digging deeper, we noticed the problem is with compilation of relative image url.
Example
Intially the image url in the browser code is:
<img src="/images/logo.png">
After refreshing the page, the image code loses the initial "/", becoming
<img src="images/logo.png">
This causes no problems when in root folder, but when in a subfolder, such as www.oursite.com/blog/pageurl, the relative image url breaks without the trailing slash.
Anyone ideas?
Thanks
Ultimate guide to setting up a Joomla MULTILANGUAGE website
https://jeyjoo.com/blog/how-to-create-a ... -joomla-3/
Guida siti MULTILINGUE in Joomla
https://jeyjoo.it/blog/creare-un-sito-m ... -joomla-3/
https://jeyjoo.com/blog/how-to-create-a ... -joomla-3/
Guida siti MULTILINGUE in Joomla
https://jeyjoo.it/blog/creare-un-sito-m ... -joomla-3/
- Jeyjoo
- Joomla! Explorer
- Posts: 344
- Joined: Tue Jul 19, 2011 8:56 am
- Location: Monaco
- Contact:
Re: Images not loading initial "/" removed
Bump - anyone?
Ultimate guide to setting up a Joomla MULTILANGUAGE website
https://jeyjoo.com/blog/how-to-create-a ... -joomla-3/
Guida siti MULTILINGUE in Joomla
https://jeyjoo.it/blog/creare-un-sito-m ... -joomla-3/
https://jeyjoo.com/blog/how-to-create-a ... -joomla-3/
Guida siti MULTILINGUE in Joomla
https://jeyjoo.it/blog/creare-un-sito-m ... -joomla-3/
-
- Joomla! Guru
- Posts: 500
- Joined: Mon Aug 11, 2008 3:05 pm
Re: Images not loading initial "/" removed
This is only a guess but perhaps you are using some process to minimize the html.
On the first view the html is served out before it's minimized in order to render the page quicker. Then just before the page is saved (cached) it's minimized. When it's minimized there could be an error in one of your regexp that strips the leading slash. Then all subsequent views of that page have an incorrect image src because they are using the cached version.
Craig
On the first view the html is served out before it's minimized in order to render the page quicker. Then just before the page is saved (cached) it's minimized. When it's minimized there could be an error in one of your regexp that strips the leading slash. Then all subsequent views of that page have an incorrect image src because they are using the cached version.
Craig
- Jeyjoo
- Joomla! Explorer
- Posts: 344
- Joined: Tue Jul 19, 2011 8:56 am
- Location: Monaco
- Contact:
Re: Images not loading initial "/" removed
Hi Craig.
We just have gzip compression and mod deflate on. I tried turning these off, but no luck.
I did remove a few plugins last month in a tidy up the site, and this is my number one suspect, though they were not plugins that should affect the urls.
Odd as we run lots of Joomla sites using the same templates and very few extensions and have never come across this problem.
Any further ideas much appreciated.
We just have gzip compression and mod deflate on. I tried turning these off, but no luck.
I did remove a few plugins last month in a tidy up the site, and this is my number one suspect, though they were not plugins that should affect the urls.
Odd as we run lots of Joomla sites using the same templates and very few extensions and have never come across this problem.
Any further ideas much appreciated.
Ultimate guide to setting up a Joomla MULTILANGUAGE website
https://jeyjoo.com/blog/how-to-create-a ... -joomla-3/
Guida siti MULTILINGUE in Joomla
https://jeyjoo.it/blog/creare-un-sito-m ... -joomla-3/
https://jeyjoo.com/blog/how-to-create-a ... -joomla-3/
Guida siti MULTILINGUE in Joomla
https://jeyjoo.it/blog/creare-un-sito-m ... -joomla-3/
- brian
- Joomla! Master
- Posts: 12787
- Joined: Fri Aug 12, 2005 7:19 am
- Location: Leeds, UK
- Contact:
Re: Images not loading initial "/" removed
Without seeing it anything anyone can suggest is pure guesswork
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/
-
- Joomla! Guru
- Posts: 500
- Joined: Mon Aug 11, 2008 3:05 pm
Re: Images not loading initial "/" removed
Jeyjoo,
mod_deflate will be more efficient than php gzip on the fly, you shouldn't use both unless you are using php gzip to create .gz files.
Are you using something like the Google pagespeed module with Apache or any other caching or minimizing software?
Craig
mod_deflate will be more efficient than php gzip on the fly, you shouldn't use both unless you are using php gzip to create .gz files.
Are you using something like the Google pagespeed module with Apache or any other caching or minimizing software?
Craig
- Jeyjoo
- Joomla! Explorer
- Posts: 344
- Joined: Tue Jul 19, 2011 8:56 am
- Location: Monaco
- Contact:
Re: Images not loading initial "/" removed
Fair point.brian wrote:Without seeing it anything anyone can suggest is pure guesswork
I corrected the issue on blog pages and second language pages using htaccess. However, the problem can be seen here:
http://jeyjoo.com/design-shack/new-logo ... case-study
Ultimate guide to setting up a Joomla MULTILANGUAGE website
https://jeyjoo.com/blog/how-to-create-a ... -joomla-3/
Guida siti MULTILINGUE in Joomla
https://jeyjoo.it/blog/creare-un-sito-m ... -joomla-3/
https://jeyjoo.com/blog/how-to-create-a ... -joomla-3/
Guida siti MULTILINGUE in Joomla
https://jeyjoo.it/blog/creare-un-sito-m ... -joomla-3/
-
- Joomla! Guru
- Posts: 500
- Joined: Mon Aug 11, 2008 3:05 pm
Re: Images not loading initial "/" removed
Jeyjoo,
Here are a couple of webpagetest examples of your page. The first one is a clean copy that isn't cached.
DNS Lookup: 1 ms
Initial Connection: 153 ms
Time to First Byte: 704 ms
Content Download: 4 ms
Bytes In (downloaded): 10.3 KB
Bytes Out (uploaded): 0.3 KB
http://www.webpagetest.org/result/15121 ... 1/details/
The second one has been cached by your server or Joomla.
DNS Lookup: 2 ms
Initial Connection: 152 ms
Time to First Byte: 260 ms
Content Download: 5 ms
Bytes In (downloaded): 10.1 KB
Bytes Out (uploaded): 0.3 KB
http://www.webpagetest.org/result/15121 ... 1/details/
The size of the second one is slightly smaller but much quicker so I know it's cached in some way. The 404 errors only seem to be srcs that start with "/images" the other images don't seem to be affected.
The first thing I would do is open a page that you know isn't cached (by adding something in the url like my examples). Then copy that source and place it in a sub directory as a flat html test file. Then open that test file with your browser. If that page opens fine the first and second time, then you know it's a Joomla problem. If it opens fine and then gets cached by something on your server and the second time the srcs of the "/images" are missing the leading slash then you know it's a server problem.
As a temporary fix you could change the srcs of those affected images to "//images...", then most likely when it's cached the first leading slash will get stripped out but leave the second. Even if they don't get stripped out //images will still work correctly.
Craig
Here are a couple of webpagetest examples of your page. The first one is a clean copy that isn't cached.
DNS Lookup: 1 ms
Initial Connection: 153 ms
Time to First Byte: 704 ms
Content Download: 4 ms
Bytes In (downloaded): 10.3 KB
Bytes Out (uploaded): 0.3 KB
http://www.webpagetest.org/result/15121 ... 1/details/
The second one has been cached by your server or Joomla.
DNS Lookup: 2 ms
Initial Connection: 152 ms
Time to First Byte: 260 ms
Content Download: 5 ms
Bytes In (downloaded): 10.1 KB
Bytes Out (uploaded): 0.3 KB
http://www.webpagetest.org/result/15121 ... 1/details/
The size of the second one is slightly smaller but much quicker so I know it's cached in some way. The 404 errors only seem to be srcs that start with "/images" the other images don't seem to be affected.
The first thing I would do is open a page that you know isn't cached (by adding something in the url like my examples). Then copy that source and place it in a sub directory as a flat html test file. Then open that test file with your browser. If that page opens fine the first and second time, then you know it's a Joomla problem. If it opens fine and then gets cached by something on your server and the second time the srcs of the "/images" are missing the leading slash then you know it's a server problem.
As a temporary fix you could change the srcs of those affected images to "//images...", then most likely when it's cached the first leading slash will get stripped out but leave the second. Even if they don't get stripped out //images will still work correctly.
Craig
- Jeyjoo
- Joomla! Explorer
- Posts: 344
- Joined: Tue Jul 19, 2011 8:56 am
- Location: Monaco
- Contact:
Re: Images not loading initial "/" removed
Thanks Craig. I turned off the Joomla "System - Page Cache" plugin (now back on), and the problem went away - so it is related to that.
Any idea what the problem may be?
Any idea what the problem may be?
Ultimate guide to setting up a Joomla MULTILANGUAGE website
https://jeyjoo.com/blog/how-to-create-a ... -joomla-3/
Guida siti MULTILINGUE in Joomla
https://jeyjoo.it/blog/creare-un-sito-m ... -joomla-3/
https://jeyjoo.com/blog/how-to-create-a ... -joomla-3/
Guida siti MULTILINGUE in Joomla
https://jeyjoo.it/blog/creare-un-sito-m ... -joomla-3/