Last active
March 20, 2019 21:04
Revisions
-
Shane Jones renamed this gist
Mar 20, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Shane Jones created this gist
Mar 20, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ /** * Function to check weather or not an image sizes exists in the thumbnail library for a specific attachment id * * @param $attachment_id - the id of any image in the se * @param $image_size_name - the name from add_image_size() * * @return bool */ function check_image_size( $attachment_id, $image_size_name ){ $image_info = wp_get_attachment_metadata( $attachment_id ); $sizes = $image_info['sizes']; if( array_key_exists($image_size_name, $sizes) ){ return true; } else { return false; } } /** Usage */ $image_exists = check_image_size( $image_id, 'thumbnail' );