Skip to content

Instantly share code, notes, and snippets.

@stefb69
Forked from SubZane/Asset.php
Last active August 29, 2015 14:23
Show Gist options
  • Save stefb69/ac6e64cc48f89ec78869 to your computer and use it in GitHub Desktop.
Save stefb69/ac6e64cc48f89ec78869 to your computer and use it in GitHub Desktop.
function get_attachment_id_from_src ($src) {
global $wpdb;
$reg = "/(-e\d{13})?(-[0-9]+x[0-9]+)?\.(jpg|jpeg|png|gif)$/i";
$src1 = preg_replace($reg,'',$src);
if($src1 != $src){
$ext = pathinfo($src, PATHINFO_EXTENSION);
$src = $src1 . '.' .$ext;
}
$query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$src'";
$id = $wpdb->get_var($query);
return $id;
}
$image_thumbnail_url = wp_get_attachment_image_src( get_attachment_id_from_src ($image_src), $thumbnail_name);
@stefb69
Copy link
Author

stefb69 commented Jun 28, 2015

Little patch that allows to have modified images within wordpress to also work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment