Last active
May 17, 2019 12:08
-
-
Save kjbenk/0fac61e2cad430ce854853598214785a to your computer and use it in GitHub Desktop.
WordPress: Check if an image URL is a crop
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 | |
function is_image_url_crop( string $image_url ) : bool { | |
// Check if this is an intermediate size image. | |
preg_match( '/-(\d+)x(\d+)\./', $image_url, $matches ); | |
if ( ! empty( $matches[0] ) ) { | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment