Last active
January 3, 2016 07:38
-
-
Save mlbd/2650ab41a12dfe5144cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get data form post meta | |
$dataMeta = get_post_meta( get_the_ID(), 'my-metafield', true ); | |
// make sure your post meta isn't empty | |
if(!empty($dataMeta)) { | |
// image url | |
$image_url = $dataMeta; | |
// retrive attachment ID | |
$id = wplap_get_attachment_id_from_url($image_url); | |
// retrieve the size of yur image that you want to set | |
$image_thumb = wp_get_attachment_image_src($id, 'custom-thumb' ); | |
// display the image url with size | |
echo $image_thumb[0].'<br />'; | |
// display as a image with size | |
echo '<img src="'.$image_thumb[0].'" width="'.$image_thumb[1].'" height="'.$image_thumb[2].'" />'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment