Created
March 25, 2016 02:23
-
-
Save QROkes/bfb3e977f49eafb3aa93 to your computer and use it in GitHub Desktop.
Download the url to a local temp file and then process it with getimagesize so we can optimize browser layout
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 | |
$img_url = 'http://someurl.com/image.jpg'; | |
if ( !empty( $img_url ) ) { | |
$tmp_file = download_url( $img_url, 10 ); | |
if ( !is_wp_error( $tmp_file ) ) { | |
$size = getimagesize( $tmp_file ); | |
$img_width = $size[0]; | |
$img_height = $size[1]; | |
unlink( $tmp_file ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment