2 added updated code
source | link

I am trying to fetch the uploaded images using the link URL (The Link URL option is available in the Add Media when we upload/insert media) and display it on web. I have gone through the methods has_post_thumbnail and the_post_thumbnail which are working perfect for me. Now, i am trying to display images (other than featured image) with certain sizing options (as available in the_post_thumbnail).

I am using the Link URL associated with the uploaded image with the help of the function $im =imagecreatefromjpeg($url[image]); and imagejpeg($im); to display it on web but all it displays it is special characters !

Is there a way to do it ?

Update code for fetching a single image from media library:

$media_query = new WP_Query
(
          array(
          'post_parent' => get_the_ID(), 
          'post_type' => 'attachment', 
          'post_status' => 'inherit',
          'post_title' => $url[image]
          )
);

foreach ($media_query->posts as $post) 
{
  print_r(wp_get_attachment_image($post->ID));
  $imageFound = true;
  break;
}

$url[image] contains the post_title. The problem is this query is fetching all the images from the media library ! Am i missing something ?

I am trying to fetch the uploaded images using the link URL (The Link URL option is available in the Add Media when we upload/insert media) and display it on web. I have gone through the methods has_post_thumbnail and the_post_thumbnail which are working perfect for me. Now, i am trying to display images (other than featured image) with certain sizing options (as available in the_post_thumbnail).

I am using the Link URL associated with the uploaded image with the help of the function $im =imagecreatefromjpeg($url[image]); and imagejpeg($im); to display it on web but all it displays it is special characters !

Is there a way to do it ?

I am trying to fetch the uploaded images using the link URL (The Link URL option is available in the Add Media when we upload/insert media) and display it on web. I have gone through the methods has_post_thumbnail and the_post_thumbnail which are working perfect for me. Now, i am trying to display images (other than featured image) with certain sizing options (as available in the_post_thumbnail).

I am using the Link URL associated with the uploaded image with the help of the function $im =imagecreatefromjpeg($url[image]); and imagejpeg($im); to display it on web but all it displays it is special characters !

Is there a way to do it ?

Update code for fetching a single image from media library:

$media_query = new WP_Query
(
          array(
          'post_parent' => get_the_ID(), 
          'post_type' => 'attachment', 
          'post_status' => 'inherit',
          'post_title' => $url[image]
          )
);

foreach ($media_query->posts as $post) 
{
  print_r(wp_get_attachment_image($post->ID));
  $imageFound = true;
  break;
}

$url[image] contains the post_title. The problem is this query is fetching all the images from the media library ! Am i missing something ?

1
source | link

Fetching uploaded images using Link URL

I am trying to fetch the uploaded images using the link URL (The Link URL option is available in the Add Media when we upload/insert media) and display it on web. I have gone through the methods has_post_thumbnail and the_post_thumbnail which are working perfect for me. Now, i am trying to display images (other than featured image) with certain sizing options (as available in the_post_thumbnail).

I am using the Link URL associated with the uploaded image with the help of the function $im =imagecreatefromjpeg($url[image]); and imagejpeg($im); to display it on web but all it displays it is special characters !

Is there a way to do it ?