Support » Alpha/Beta/RC » Image post-format, get id of attached image

  • Resolved veuse

    (@itworx)


    I need to get either the image url or image id of the post_format_image, as I want it do do some dynamic image resizing. Anyone know how to do this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Your site URL?

    Image src or id…

    Why has this thread been moved to “How-To and Troubleshooting”? This question is related to the new post-format functionality in wp 3.6

    Is it OK now?

    That’s better. Thanks.

    Seems there is no built-in method for retrieving the image src, but it can be done with a preg_match:

    function get_post_format_image_src($post_id){
    
    	$format_meta = get_post_format_meta($post_id);
    	$match = array();
    	preg_match('/<img.*?src="([^"]+)"/s', $format_meta['image'], $match);
    	return $match[1];
    }

    This will return the image src.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Image post-format, get id of attached image’ is closed to new replies.