WordPress.org

Support

Support » Plugins and Hacks » Retrieving images, setting default size in the function

Retrieving images, setting default size in the function

  • Using this code, is there a way to set the size of the default image?

    function catch_that_image() {
    global $post, $posts;
    $first_img = ”;
    ob_start();
    ob_end_clean();
    $output = preg_match_all(‘/<img.+src=[\'”]([^\'”]+)[\'”].*>/i’, $post->post_content, $matches);
    $first_img = $matches [1] [0];

    if(empty($first_img)){
    $first_img = “/images/default.jpg”;
    }
    return $first_img;
    }

  • The topic ‘Retrieving images, setting default size in the function’ is closed to new replies.