0

I have a created a custom post type and gave it a field of image which can contain a gallery. When I'm inside content.php I can call up all available data such as title, postmeta and such just fine but some of the post's images are given width=1 height=1 in the <img> if I use the_post_thumbnail('medium') or the_post_thumbnail(array(300,300)).

Im not sure if there is a database issue or a fault with the image that I'm unaware of.

1
  • I ran thumbnail resizer and it corrected the issue, I still want to know what was causing this because I have no way of know if this will occur again. – swgamerx150 Aug 5 '15 at 23:48
2

It's only a guess, but it's also most probable cause...

When you upload an image to WP, some metadata is generated and stored in database. This metadata contains such info like name, path and size of the image (to be more precise - paths and sizes of all created images based on uploaded one). And... This metadata is stored as serialized array.

When the metadata is corrupted (so WP is not able to unserialize it), it can cause images with size 1x1 (WP doesn't know what is the size of given image).

What should you do in such case?

It's easy to correct this. All you need to do is to regenerate metadata for these images. (There are many plugins which will help you with this - look for "regenerate thumbnails" or "rebuild" thumbnails").

0

It happened to me when I introduced new custom image sizes and did not regenerate the thumbnails. It seems that WP searches for the proper thumbnail, and when it is not found, has some problem in calculating the proper size.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.