Coding Cheatsheets - Learn web development code and tutorials for Software developers which will helps you in project. Get help on JavaScript, PHP, XML, and more.

Post Page Advertisement [Top]

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 );

No comments:

Post a Comment

Bottom Ad [Post Page]