Skip to content

Instantly share code, notes, and snippets.

@jessekanner
Created August 27, 2021 15:10
Show Gist options
  • Select an option

  • Save jessekanner/33b901584be9e0ade130fa34c748437c to your computer and use it in GitHub Desktop.

Select an option

Save jessekanner/33b901584be9e0ade130fa34c748437c to your computer and use it in GitHub Desktop.
Display a PDF thumbnail in WordPress front end
/* --- Used to display thumbnails automatically created by WordPress --- */
// Get attachement ID (this is circuitous, but seems to be the most "wordpress" way w/o needing plugins, etc
$attachment_id = array_keys(get_attached_media('*,*',$post->ID))[0];
// Once you have the attachment_id, proceed as normal
echo wp_get_attachment_image( $attachment_id, 'full', $icon, $attr );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment