Retrieve featured image

The featured image attachment id is stored in the post_meta table, with the meta_key _thumbnail_id.

Use that post id to find the post meta with meta_key _wp_attachment_metadata.

The value of that is a serialized array with keys thumb, file, width, height, sizes (an array), and image_meta (an array).

The file value is relative to the uploads directory for the WP install, and points to the original full-sized image. You should be able to calculate the URL from that.

sizes has an image size as its key (e.g., ‘small’, ‘medium’, ‘large’, ‘thumbnail’), and the value is an array with keys file, height, and width.

image_meta will contain things like exif/iptc image metadata from the image itself.

Leave a Comment