Remove the sizes from the WordPress image filenames that have the width and height added to the original file name. For example, this takes the medium or thumbnail image name, such as “image-150×150.jpg”, and it will return the originally uploaded image filename, which in this example is “image.jpg”.
function isa_original_image_name($filename){ return preg_match('/\-\d{2,4}x\d{2,4}\./', $filename, $matches) ? str_replace($matches[0], '.', $filename) : $filename; }
Questions and Comments are Welcome