Created
March 8, 2017 15:44
-
-
Save rafaelcavalcante/885b6b4356eaf8fb4cd495eaf757f175 to your computer and use it in GitHub Desktop.
the_penck_thumbnail()
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
<?php | |
/* | |
PT: O snippet "penck thumbnail" foi feito para exibir | |
o caminho da imagem de acordo com o objeto de imagem retornado do | |
plugin Advanced Custom Fields | |
EN: The penck thumbnail snipper were made to output the | |
image path according to the image object returned by the | |
Advanced Custom Fields plugin | |
*/ | |
add_image_size('blog-thumbnail-2x', 1920, 1080, array( 'center', 'center' ) ); | |
add_image_size('blog-thumbnail-1x', 960, 540, array( 'center', 'center' ) ); | |
function the_penck_thumbnail($fieldname, $size) { | |
$attachment_id = get_field($fieldname); | |
$url = wp_get_attachment_image_src( $attachment_id, $size )[0]; | |
echo $url; | |
} | |
/* | |
USAGE | |
the_penck_thumbnail('the-image-field-name','the-size-to-show'); // http://github.com/blog/uploads/image.jpg | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment