Image sizes lost
-
I’ve encountered a strange issue with galleries on a few of my WordPress blogs, and whilst a similar issue is mentioned in some other posts they seem to all refer to an issue with PodPress, a plugin which I am not using on any of the affected sites.
Basically since we moved server a few of the 25 or so WP installs we have seem to have had images that were uploaded into a gallery on post/page have lost all info relating to image size and the fact that thumbnails have been generated for these images. I would have assumed this was totally related to moving server, but am unsure of this because of the fact that many of the WP installs with galleries haven’t been affected.
So if you look at this post on my own blog (co-incidentally about wp’s gallery function).
https://alex.leonard.ie/2008/06/03/wordpress-25-gallery-templating/you’ll notice that all of the images are loading as full sized images and hence overlap each other and so on.
In the gallery screen of this post each image displays with no option on thumbnails etc, and the full size image is automatically selected and reports a size of 0x0. Screen shot below:
https://alex.leonard.ie/misc-images/alexleonard-gallery-issue01.png
So I’ve been investigating a few of the possible things that could cause this. I’ve looked closely at the uploaded file permissions, groups and ownership, and have been able to compare them against another gallery on a working site on the same server:
https://www.invisibleagent.com/2007/04/15/hotel-ballymun-photos/
As best as I can see the permissions and ownership shouldn’t be causing any issue.
After this I’ve been looking closely at the wp_posts and wp_meta tables in the db containing these attachments, and, well, everything *looks* fine.
So the above example has a photo called kerry-morning which is in wp_posts as:
mysql> SELECT * FROM wp_posts WHERE guid LIKE "%kerry-morning%"; | ID | post_author | post_date | post_date_gmt | post_content | post_title | post_category | post_excerpt | post_status | comment_status | ping_status | post_password | post_name | to_ping | pinged | post_modified | post_modified_gmt | post_content_filtered | post_parent | guid | menu_order | post_type | post_mime_type | comment_count | | 26 | 1 | 2008-06-03 16:28:58 | 2008-06-03 16:28:58 | This is taken down in Kerry when myself and a load of friends spent a weekend on Valentia Island. Needless to say, dawn was only captured having stayed up all night. | kerry-morning-mist | 0 | Beautiful mist at sunrise | inherit | open | open | | kerry-morning-mist | | | 2008-06-03 16:28:58 | 2008-06-03 16:28:58 | | 21 | https://alex.leonard.ie/wp-content/uploads/2008/06/kerry-morning-mist.jpg | 0 | attachment | image/jpeg | 0 | 1 row in set (0.00 sec)
I can then match this attachment up with it’s data in the wp_postmeta table thus:
SELECT * FROM wp_postmeta WHERE post_id = 26; | meta_id | post_id | meta_key | meta_value | | 79 | 26 | _wp_attached_file | /local/path/to/wp-content/uploads/2008/06/kerry-morning-mist.jpg | | 80 | 26 | _wp_attachment_metadata | a:6:{s:5:"width";i:500;s:6:"height";i:335;s:14:"hwstring_small";s:23:"height='85' width='128'";s:4:"file";s:93:"/local/path/to/wp-content/uploads/2008/06/kerry-morning-mist.jpg";s:5:"sizes";a:2:{s:9:"thumbnail";a:3:{s:4:"file";s:30:"kerry-morning-mist-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;}s:6:"medium";a:3:{s:4:"file";s:30:"kerry-morning-mist-300x201.jpg";s:5:"width";i:300;s:6:"height";i:201;}}s:10:"image_meta";a:10:{s:8:"aperture";i:0;s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";i:0;s:9:"copyright";s:0:"";s:12:"focal_length";i:0;s:3:"iso";i:0;s:13:"shutter_speed";i:0;s:5:"title";s:0:"";}} |
So that *looks* alright, I think.
I’ve compared the last files meta_key of _wp_attachment_metadata against one of the photos on Invisible Agent to see if there’s any difference, and that comes back as:
| meta_id | post_id | meta_key | meta_value| | 3574 | 595 | _wp_attached_file | 2009/01/070415-hotel-ballymun_07.jpg | 3575 | 595 | _wp_attachment_metadata | a:6:{s:5:"width";s:3:"600";s:6:"height";s:3:"450";s:14:"hwstring_small";s:23:"height='96' width='128'";s:4:"file";s:36:"2009/01/070415-hotel-ballymun_07.jpg";s:5:"sizes";a:2:{s:9:"thumbnail";a:3:{s:4:"file";s:36:"070415-hotel-ballymun_07-150x150.jpg";s:5:"width";s:3:"150";s:6:"height";s:3:"150";}s:6:"medium";a:3:{s:4:"file";s:36:"070415-hotel-ballymun_07-300x225.jpg";s:5:"width";s:3:"300";s:6:"height";s:3:"225";}}s:10:"image_meta";a:10:{s:8:"aperture";s:3:"2.8";s:6:"credit";s:0:"";s:6:"camera";s:19:"Canon PowerShot A95";s:7:"caption";s:14:"Serious Intent";s:17:"created_timestamp";s:10:"1176670075";s:9:"copyright";s:0:"";s:12:"focal_length";s:6:"7.8125";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:3:"0.5";s:5:"title";s:0:"";}} |
And boy is there a difference! Where? What? Looks like the broken galleries have the same thing in common – with in wp_postmeta both the _wp_attached_file and _wp_attachment_metadata are using the full local path (such as /home/virtualsites/domain/httpdocs/wp-content/etc) whereas the galleries which are working are loading the above meta_values as a relative path (relative to wp-content/uploads/).
Now as my MySQL Fu is not very strong I’ve mailed our server admin about this and will hopefully go through doing some tests in the morning and confirming whether this is what is causing the issue.
Is this a bug? Would other people whose image sizes have been lost find the same thing?
Does this sound plausible? Has something changed in the core code recently which has changed the DB entries for _wp_attached_file and _wp_attachment_metadata to work off a relative path to the upload folder location rather than a full local path?
If so is there a reason why WP version upgrades haven’t updated this data in the database?
Or am I barking up the wrong tree?
??
Cheers,
Alex
- The topic ‘Image sizes lost’ is closed to new replies.