How to show featured image (medium sized) relative URL (relative to the website root)?
I need something like this: uploads/214/07/image-600x400.png
I tried with this:
if ( has_post_thumbnail()) {
$medium_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium');
echo $medium_image_url[0];
}
It works fine, I get path of medium sized featured image, but with domain name too, and I need it without domain name.
Also I tried like this:
global $wpdb;
$the_thumbnail_id = get_post_thumbnail_id($post->ID);
$the_thumbnail_name = $wpdb->get_var( "SELECT meta_value FROM $wpdb->postmeta WHERE post_id = '$the_thumbnail_id' AND meta_key = '_wp_attached_file'" );
//
echo $the_thumbnail_name;
This works fine, I get just relative path, but "full" sized featured image path, and I need "medium" sized featured image path.
Can anyone help me, maybe redesign (adding some parameter for "medium" size) of second function, or some new approach?
echo getSize('medim-size-url-here.jpg');