• Resolved johnny-b

    (@johnny-b)


    Quick question: How does the Media Library know when there is a thumbnail attached to an uploaded image? In other words, how does WP determine whether to show the thumbnail or the default.jpg for an image?

    I don’t see a flag or otherwise for thumbnails in the posts table. In edit-attachment-rows.php (which is the Media Library uploads listing as far as I can tell), the wp_get_attachment_link() is called. I’ve been trying to trace this through to its conclusion, but I haven’t been able to pinpoint that piece of logic that decides to show the thumbnail or not. At first I assumed it was simply checking for the ‘-150×150’ appendage, but now I’m not so sure.

    Any and all suggestions are appreciated. Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try looking in the wp_postmeta table.

    Each uploaded image has a wp_posts record with a post_type of “attachment”.

    Each of these wp_posts record should have a corresponding wp_postmeta record with a meta_key of _wp_attachment_metadata.

    The meta_value for this record contains a (serialized) array of data relating to the uploaded image.

    You probably want the value of $array[sizes][thumbnail][file]

    Thread Starter johnny-b

    (@johnny-b)

    James, this was the information I needed, thank you for responding. I wrote a little script to generate the serialized array and it worked like a charm…that is, thumbnails appeared. I think you are correct, then, that the postmeta table is the determining factor as to whether the thumbnail is shown. Again, thank you for your help, it is appreciated ??

    Hi Johnny, good to hear you got it working in the end.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How does WP determine if a thumbnail exists?’ is closed to new replies.