VIP-Coding-Standards icon indicating copy to clipboard operation
VIP-Coding-Standards copied to clipboard

Sniff for getimagesize()

Open davidsword opened this issue 4 years ago • 0 comments
trafficstars

What problem would the enhancement address for VIP?

getimagesize() holds up the PHP process downloading the entire image to just read its file size.

Describe the solution you'd like

Most images in WPs Media Library have width and height attributes already (like from wp_get_attachment_metadata()) & that existing data should be used instead.

If the image is external and not in WordPress' media library, perhapes:

What code should be reported as a violation?

$size = getimagesize( $image_url );
list($width, $height) = getimagesize( $image_url );
//etc.

davidsword avatar May 21 '21 18:05 davidsword