Skip to content

Instantly share code, notes, and snippets.

@QROkes
Created March 25, 2016 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save QROkes/bfb3e977f49eafb3aa93 to your computer and use it in GitHub Desktop.
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
<?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