Created
October 19, 2023 23:15
-
-
Save robertdevore/335964fb9d85bf7a9ba8ca5bf00080c1 to your computer and use it in GitHub Desktop.
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 characters
<?php | |
/** | |
* Get explicit image sizes | |
* | |
* @param string $image_url The image URL - https:// ... | |
* | |
* @return string | |
*/ | |
function get_explicit_image_sizes( $image_url ) { | |
$img_explicit = ''; | |
if ( $image_url ) { | |
$logo_media_id = get_media_id_from_url( $image_url ); | |
$img_dimensions = get_image_sizes_by_id( $logo_media_id ); | |
if ( $img_dimensions ) { | |
$img_explicit = ' width="' . $img_dimensions['width'] . '" height="' . $img_dimensions['height'] . '" '; | |
} | |
} | |
return $img_explicit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment