WordPress.org

Ready to get started?Download WordPress

Forums

Retrieving images, setting default size in the function (1 post)

  1. akinoluna
    Member
    Posted 4 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.