WordPress.org

Ready to get started?Download WordPress

Forums

i need functions (1 post)

  1. progpars
    Member
    Posted 2 years ago #

    hi
    i need to a function to get new thumbnail in any size. for example 200x200
    For example :

    <?php
    // get the first image attached to the current post
    function aldenta_get_post_image($size = 'thumbnail') {
    global $post;
    
    $photos = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
    
    if ($photos) {
    $photo = array_shift($photos);
    return wp_get_attachment_image($photo->ID, $size);
    }
    else{
    	return '<img src="'.get_bloginfo('template_url').'/default.jpg" border="0" />';
    }
    return false;
    }
    ?>

    echo thumb:
    <?php echo aldenta_get_post_image();?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.