I'm doing a custom gallery for a portfolio page in a website and It works well if I simply use the URL of the media uploaded this way :
SELECT * FROM wp_posts AS p INNER JOIN wp_postmeta AS m ON p.ID=m.post_id
WHERE p.post_type='attachment' AND m.meta_key='_wp_attached_file'
The thing is, if I upload too many big files, the page gets sloooow. This is why I'd like to use thumbnail but I have no idea how to select them accordingly in the database.
They're created in the wp-content/uploads folder, but I can't see which meta_key
to select in the database.
Also noticable, my databse doesn't have any "_thumbnail_id"
in the meta_key
column.
Anyone has an answer ?
WP_Query
? orget_posts()
or something? Could you maybe include the code that shows what you're doing with the results?_wp_attachment_metadata
, but you're going to need to unserialize and handle any missing sizes yourself. It'll be much easier if you use WordPress functions.