Here are simple way to get custom image from URL
$imgUrl = 'http://localhost/wptest/wp-content/themes/sydney/images/header.jpg';
global $wpdb;
$attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $imgUrl ));
$image_id = $attachment[0];
$thumbnail_url = wp_get_attachment_image_src($image_id, array('615','440'), true );
$imgUrl = 'http://localhost/wptest/wp-content/themes/sydney/images/header.jpg';
global $wpdb;
$attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $imgUrl ));
$image_id = $attachment[0];
$thumbnail_url = wp_get_attachment_image_src($image_id, array('615','440'), true );
No comments:
Post a Comment