Zen Cart Logo
Forums / General Questions / Some images are broken?

Some images are broken?

Views: 2,358

Results 1 to 14 of 14
12 Apr 2014, 11:22 PM
#1
smarmyclothes avatar

smarmyclothes

New Zenner

Join Date:
Feb 2009
Posts:
36
Plugin Contributions:
0

Some images are broken?

I'm having an odd issue with my site. Some of my images are suddenly showing up as broken links.

EXAMPLE: http://whatthecraft.com/shop/index.php?main_page=product_info&cPath=1&products_id=78

On the above page, there should be an image under the "FAQs" in the product description with information about a coupon code. It's no longer showing up. I double checked that the image is in the correct location and even re-uploaded it, which did nothing.

Some of the images are "half working". If you look at that same page I linked to above, all of the product images will load the larger pop-up image fine EXCEPT for the very last image. Again, I double checked the file location and re-uploaded it, and it still doesn't show up. My other listings have similar problems. Most of the images pop-up properly, but one or two load a blank pop-up.

For the image pop-ups that do work, I noticed that if I copy the image location, the URL looks like this:
http://whatthecraft.com/shop/bmz_cache/0/0eb0e092cc3a83b7e8e5ff145cf7d4ea.image.397x550.jpg

For the images with the pop-ups that aren't working, the image URL looks like this:
http://whatthecraft.com/shop/images/patterns14/retro_rockabilly_swing_dress_pattern_06.jpg

I thought this might be an issue with Image Handler, so I reinstalled it, but it didn't seem to help.

Also, I'm not sure if this problem is related or not, but if I try to navigate to the image URLs (http://whatthecraft.com/shop/images/buymoresave.jpg), it says "Under Maintenance". The same goes for trying to navigate to every image on my site, even the ones that are showing up properly.

Aside from the reinstallation of IH4 earlier today, I haven't made any changes to the site in quite some time. The most recent change to my site was switching hosts a few months back, though I don't know if this problem started then or more recently.

13 Apr 2014, 10:08 AM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Some images are broken?

The problem is related to file permissions.

Failed to load resource: the server responded with a status of 403 (Forbidden)
--------------------------------------

Cheers
RodG

13 Apr 2014, 3:54 PM
#3
smarmyclothes avatar

smarmyclothes

New Zenner

Join Date:
Feb 2009
Posts:
36
Plugin Contributions:
0

Re: Some images are broken?

All of my image directories are set to 755. The files are set to 644. Am I missing something?

13 Apr 2014, 4:34 PM
#4
smarmyclothes avatar

smarmyclothes

New Zenner

Join Date:
Feb 2009
Posts:
36
Plugin Contributions:
0

Re: Some images are broken?

I've been searching all last night and this morning for someone else experiencing a similar problem. The closest I could find was this person having issues with Wordpress after moving from shared hosting to VPS: https://wordpress.org/support/topic/broken-images-after-moving-from-shared-hosting-to-vps

They finally solved it by installing some Apache modules. I did have some issues when I first moved my site and had to install GD Library. So I just rebuilt Apache with the following: Zip Module, mCrypt module, mbString module, and MySQLi. It doesn't seem to have worked.

Most of the server stuff is way over my head anyway, so I don't even know if I was even on the right track with that. :/

Also, I don't think I made this clear before, but the thing I find most confusing is that this isn't effecting just the old images or just the new images. It's some of both. I added 2 new products last night and out of 12 images, only 2 don't work.

13 Apr 2014, 5:17 PM
#5
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Some images are broken?

smarmyclothes:

The closest I could find was this person having issues with Wordpress

The fact that you have a wordpress installation did cross my mind, but I was hoping it wouldn't come to that.

Could you please take a look at the file /images/index.html and see if it contains "Under Maintenance". (A default installation doesn't have this).
Based on the assumption that yours doesn't either, we have to assume that this text is being generated by WordPress, but why WordPress would be reacting to stuff in the zencart/images folder is a bit of a mystery to me.

My gut feeling is telling me that you have a rule in your .htaccess file (top level) that is causing a redirect or rewrite going on. (Assuming all file/folder permissions are correct). Hmmm, as well as permissions, you should also take note of the 'ownership' of the files. This normally isn't an issue, but they can get messed up if the site has been relocated from another server.

smarmyclothes:

They finally solved it by installing some Apache modules. I did have some issues when I first moved my site and had to install GD Library. So I just rebuilt Apache with the following: Zip Module, mCrypt module, mbString module, and MySQLi. It doesn't seem to have worked.

This doesn't look or behave like a server issue. A configuration issue, yes.

smarmyclothes:

Most of the server stuff is way over my head anyway, so I don't even know if I was even on the right track with that. :/

Probably not. As long as you didn't make things any worse it was worth a shot though.

smarmyclothes:

Also, I don't think I made this clear before, but the thing I find most confusing is that this isn't effecting just the old images or just the new images. It's some of both. I added 2 new products last night and out of 12 images, only 2 don't work.

This could be a clue. How are you uploading the images?

Could you also provide the name of one of these new images that you are NOT having a problem with. I'm not sure if it'll help or not, but I'd like to see and confirm this for myself (Not that I don't trust your findings), but if true, then my initial gut feeling doesn't hold much water.

Another thing for you to do (Not as a fix, but as a process of elimination) is to rename or delete your .htaccess file (make a backup copy before deleting). See if the problem goes away. ZenCart doesn't need this file. (Wordpress does).

I'm trying to determine whether it is wordpress related, or ZenCart specific.

Another thing to try is set the permissions on your /images/ folder to '777' (IF you get a server error try 775)
You can also try setting one of the images with the problem to 666 (with the folder still set to 777 or 775).

These are about as 'relaxed' as the permissions can be and even if the 'ownership' is mussed up these permissions should allow anyone to read the files.

So, several things for you to do and check, I'm sure that at least one of them will provide the clues we need to narrow things down.

Cheers
RodG

13 Apr 2014, 5:36 PM
#6
smarmyclothes avatar

smarmyclothes

New Zenner

Join Date:
Feb 2009
Posts:
36
Plugin Contributions:
0

Re: Some images are broken?

I don't appear to have a /images/index.html file

All of the owner/group settings are 500 501 for both the files and directories.

Changing the file and directory permissions to 666 and 777 respectively did not work.

Here's an image I uploaded last night that works:
http://whatthecraft.com/shop/bmz_cache/2/265a975ce0ca9b1889c195e6894c971e.image.750x728.jpg

However, only the bmzcache version works. The actual file gives the same error:
http://whatthecraft.com/shop/images/patterns14/retro_rockabilly_swing_dress_pattern_03.jpg

I uploaded the images via FTP.

The bmzcache issue makes me think something is going on with Image Handler- though I'm not sure if I have two separate problems (Image Handler not caching some images AND something with the permissions) or just one.

I've been trying to figure out if there's a pattern, and I finally noticed one: all of the images that have no cached version are short. Most of my images are similar width-wise, but the ones that don't work are all under a certain number of pixels in height.

13 Apr 2014, 8:49 PM
#7
smarmyclothes avatar

smarmyclothes

New Zenner

Join Date:
Feb 2009
Posts:
36
Plugin Contributions:
0

Re: Some images are broken?

Update: I decided to uninstall IH4. The result is that now none of my images work, I guess because the cached versions are gone.
I re-installed IH4, but the images still don't work (not a surprise).

On the bright side, I guess I can say for sure that it's not a problem with IH4. :P

13 Apr 2014, 9:13 PM
#8
smarmyclothes avatar

smarmyclothes

New Zenner

Join Date:
Feb 2009
Posts:
36
Plugin Contributions:
0

Re: Some images are broken?

Alright, I posted too soon. When I reinstalled IH4, I forgot to set "IH resizes images" to Yes. So my images are showing up again- still having the issues with the actual image URLS not working, just the bmzcache versions show up.

Also, I tried increasing the size of one of the "short" images, as I mentioned above, and that image (bmz cache version) works now. So I don't know why the pixel height matters, but for some reason, it does.

14 Apr 2014, 10:12 AM
#9
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Some images are broken?

smarmyclothes:

I don't appear to have a /images/index.html file

I can only guess it has been deleted at some time. This has been a part of the zencart installation files since at least V1.3.7.

It's probably not important that its missing. I was thinking that this could be where the "Under Maintenance" text was coming from. Since the file doesn't exist it can't be coming from there.

smarmyclothes:

All of the owner/group settings are 500 501 for both the files and directories.

Alas, I am unable to tell you if this is correct or not. This will be different from server to server and owner to owner. The important thing in this case is that they are consistent. )bad files and good files).

smarmyclothes:

Changing the file and directory permissions to 666 and 777 respectively did not work.

This comes as a little bit of a surprise. I would suggest you leave them this way, at least until the issue has been solved (just in case there is a combination of factors at play, with this being one of them)

smarmyclothes:

Here's an image I uploaded last night that works:
http://whatthecraft.com/shop/bmz_cache/2/265a975ce0ca9b1889c195e6894c971e.image.750x728.jpg

However, only the bmzcache version works. The actual file gives the same error:
http://whatthecraft.com/shop/images/patterns14/retro_rockabilly_swing_dress_pattern_03.jpg

This is exactly what I was going to be looking for. You've saved me the trouble. :)

smarmyclothes:

I uploaded the images via FTP.

You should double check that the uploads are being successfully completed.. (Compare the filesizes)

smarmyclothes:

The bmzcache issue makes me think something is going on with Image Handler- though I'm not sure if I have two separate problems (Image Handler not caching some images AND something with the permissions) or just one.

This is also my line of thought, but the two could be related... if IH4 can't read the /images/ files it won't be able to create the cached versions, so only the previously cached versions will be shown... BUT, my thoughts are that since the images can't be viewed via a direct link due to the permissions error then this is most likely to be the source of the problem, so in my mind, step#1 to resolving the issue is to get the files readable via a direct link (and hopefully that would also allow IH4 to read and cache them)... problem solved - Well, that was my theory.

smarmyclothes:

I've been trying to figure out if there's a pattern, and I finally noticed one: all of the images that have no cached version are short. Most of my images are similar width-wise, but the ones that don't work are all under a certain number of pixels in height.

I've never heard about this happening before, and I'm not saying you are wrong.... I'm still at the stage of trying to figure out why none of the files in the /images/ folder are readable via a direct link. Or am I mistaken here? I am somewhat limited in my testing here because I can only test using the names of the files that you've told me about. Having said that, I did try using a couple of 'known' images (call_for_price.jpg and no_picture.gif) with very confusing results.

In both cases, the main page gets displayed rather than the actual images. ZenCart doesn't generally do this (in my experience), which leads me back to thinking that there is a redirect/rewrite going on (.htaccess file?) or perhaps some processing that your WP is doing(???). This is why I suggested you rename or delete the .htaccess file so as to eliminate this possibility.

The other oddity I noticed was that a request to view the 'call_for_price.jpg file gives the following error:

Resource interpreted as Image but transferred with MIME type text/html:
--------------------------------------------------------------------------------------

The no_picture.gif has the same redirect going on, but without any error being reported.
I haven't quite figured out what this means yet, but I'm convinced it is somehow relevant to the problem(s)

smarmyclothes:

Alright, I posted too soon. When I reinstalled IH4, I forgot to set "IH resizes images" to Yes. So my images are showing up again- still having the issues with the actual image URLS not working, just the bmzcache versions show up.

Are all the images now showing, or is it still only the ones that have been previously cached?

smarmyclothes:

Also, I tried increasing the size of one of the "short" images, as I mentioned above, and that image (bmz cache version) works now. So I don't know why the pixel height matters, but for some reason, it does.

Very interesting. I don't suppose you've figured out at exactly what pixel height it fails? (I'm not sure how important this could be, but if you find it needs to be under (say) 10px, then perhaps searching through the code for this value may determine if a coded limitation has been met. (Clutching at straws here).

Another thing I would suggest would be to disable/uninstall IH4 and see what happens. Although I've never actually found IH4 to be the cause of any issues, in a case like this it will be prudent to at least get things working without this add-on. If you can do this, and then find the problem returns when re-installed we can then concentrate solely on what IH4 is doing without concerning ourselves with possible permissions errors. If you still have the problem without IH4 we would have eliminated this as having any bearing on the matter, which will reduce the number of places to look for the apparent size related matter.

So there you have it.
Remove/delete your .htaccess file. Remove or disable IH4, and that will give us a pretty good place for further diagnosis.

Its the old Sherlock Holmes adage. "when you have eliminated the impossible, whatever remains, however improbable, must be the truth".

What we are doing is eliminating as much as we can to narrow down the cause.

Cheers
RodG

14 Apr 2014, 7:05 PM
#10
smarmyclothes avatar

smarmyclothes

New Zenner

Join Date:
Feb 2009
Posts:
36
Plugin Contributions:
0

Re: Some images are broken?

Thank you for helping me with this. I really appreciate it.

And sorry for the confusing mess of posts. I'll try not to bounce around so much. :D In all of the above posts, when I say the images "work", I mean the pop ups work correctly- but only the cached versions. I still can't view them via direct link.

Also, I should point out that my template images are accessible via direct link (logo, etc.). This problem seems to be only effecting the images in the /images folder. Link to the functioning logo, for example: http://whatthecraft.com/shop/includes/templates/wtc/images/shoplogo.png

In terms of Image Handler: I uninstalled it yesterday, which included deleting all of the cached images and folders. The result was that none of my images showed up. No thumbnails, nothing. Nor were they accessible via direct link.

I reinstalled Image Handler, thinking perhaps it would cache all of the images, even if it wouldn't fix the permissions issue. It cached the exact same images as before. So as it stands now, the cached images show up, but again, none of them are accessible via direct link.

And I think I've solved the mystery as to why there aren't cached versions of the "shorter" images. I have Image Handler set to resize images that are larger than 750 px wide and 550 px tall. The images under 550 px are not being resized, and thus are not being cached. So I suppose I have IH to thank for my site being at all functional at this point. :)

So on to the .htaccess file. I deleted the top level file. The images are still not accessible, but it did get rid of the "Under Maintenance" message. Now it's just a generic "Forbidden" error.

Example: http://whatthecraft.com/shop/images/patterns14/rockabilly_pencil_skirt_sewing_pattern_03.jpg

/images directory is still set to 777 with the images set to 666.

14 Apr 2014, 7:12 PM
#11
smarmyclothes avatar

smarmyclothes

New Zenner

Join Date:
Feb 2009
Posts:
36
Plugin Contributions:
0

Re: Some images are broken?

Well, the solution is probably the easiest thing I could have done and didn't think of or try... there was an .htaccess file in the /images folder itself. I deleted it and now EVERYTHING works.

Do I need an .htaccess file in the /images directory?

15 Apr 2014, 7:28 AM
#12
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Some images are broken?

smarmyclothes:

Well, the solution is probably the easiest thing I could have done and didn't think of or try... there was an .htaccess file in the /images folder itself. I deleted it and now EVERYTHING works.

Hindsight is always 20/20.

It's like looking for missing keys. They are always in the last place you look (and then its obvious where you left them)

smarmyclothes:

Do I need an .htaccess file in the /images directory?

Need ....... No.
Should you have one?.... Yes.

The purpose of the .htaccess file in this folder is for security reasons. It makes it so that only image files can be read, and this is is to prevent hackers from using this folder to store and execute their .php scripts (This was one of the symptoms of a well known exploit in ZenCart 1.3.8).

Although this exploit has long been fixed, it is still good practice to prevent anything other than image files to be loaded from here.

The default .htaccess file provided by the ZenCart distribution files don't cause the problem that you were having, so yours has probably been modified at some stage. Replace it with an original copy and all should be fine.

Cheers
RodG

15 Apr 2014, 8:04 AM
#13
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: Some images are broken?

Autopsy Report

smarmyclothes:

Thank you for helping me with this. I really appreciate it.

No worries. I actually quite enjoy trying to solve these mysterious/unusual issues. I like the challenge :)

smarmyclothes:

I reinstalled Image Handler, thinking perhaps it would cache all of the images, even if it wouldn't fix the permissions issue.

It actually works the other way around. The permissions need to be correct so that IH4 can read and cache them.

smarmyclothes:

It cached the exact same images as before. So as it stands now, the cached images show up, but again, none of them are accessible via direct link.

It was actually this behaviour (some images work, others don't) that made me think that the problem wasn't caused by the .htaccess file in the images folder as about the only thing in this file that would cause this is if one (or more) of the file extensions had been removed from the "FilesMatch" list.... and no one ever does that. :)

The finding that the size of the file was related to the problem reinforced the idea that it wasn't related to this .htaccess file.

smarmyclothes:

And I think I've solved the mystery as to why there aren't cached versions of the "shorter" images. I have Image Handler set to resize images that are larger than 750 px wide and 550 px tall. The images under 550 px are not being resized, and thus are not being cached. So I suppose I have IH to thank for my site being at all functional at this point. :)

Totally unexpected, but definitely true.

Mind if I ask why you have set IH to only resize the larger images though? There's no real need for this (as far as I'm aware) as it will only resize the images that actually need resizing and it does this to improve performance and reduce bandwidth. Without it, if your original image is (say) 640x320 and it is required to be displayed as a thumbnail/small image then the full size image is sent to the browser, which then has to resize it according to the image settings. On the other hand, if you have IH resize this image it does it once only (and stores it in its cache) and the smaller image is sent to the browser (less data, better performance) and no further resizing is needed by the browser (so it will also render faster). It's a win, win, win situation.

smarmyclothes:

So on to the .htaccess file. I deleted the top level file. The images are still not accessible, but it did get rid of the "Under Maintenance" message. Now it's just a generic "Forbidden" error.

The 'Under Maintenance' message is still a mystery to me. It is 'obviously' the result of a redirect as a result of the forbidden error, and as such, it is probably quite harmless. It did complicate the diagnosis a little though (not your fault). It was just something that we needed to eliminate so we could hone in on the actual problem.

smarmyclothes:

/images directory is still set to 777 with the images set to 666.

Now that the cause of the issue has been found you should set these back to their default permissions. (755 & 644).

So, after a few red herrings, a bit of trial and error, the cause has been found in one of the places I least expected. All in all, quite a worthy and educational exercise (for me). I'm sorry that it must have been very frustrating for you though, and I give my utmost thanks for 'humouring' me by following my suggestions. The cause wouldn't have been found without your help.

Cheers
RodG

15 Apr 2014, 5:02 PM
#14
smarmyclothes avatar

smarmyclothes

New Zenner

Join Date:
Feb 2009
Posts:
36
Plugin Contributions:
0

Re: Some images are broken?

I doubt I would have tried anything with the .htaccess file if you hadn't mentioned it, so I think the credit still goes to you. :)

The resizing on the large image was the default setting when I installed IH4. I turned that setting off when I reinstalled but turned it back on when I realized that the resizing/caching was the only thing making my images show up (before I fixed the real problem). But I had forgotten to turn it back off now that things are fixed, so thanks for the reminder!

I reset the permissions and downloaded a fresh copy of Zen Cart so I could upload clean versions of the .htaccess file and index.html for the /images directory. Everything is still working, so yay!

Thank you again for your help!