WordPress.org

Ready to get started?Download WordPress

Forums

Setting attachment size dynamically (2 posts)

  1. richgcook
    Member
    Posted 1 year ago #

    Hi folks,

    With the function 'wp get attachment image' you can set the size to use, however, I am wanting the size to be set by whatever the user picks for the image in the media uploader. Is this possible? Currently we have to set 'medium', 'full' etc, but surely it would work if we could set whatever the user selects.

    Currently my code looks like this:

    <ul class="project-individual-image-container">
    <?php
    $args = array(
    	'post_type' => 'attachment',
    	'post_status' => null,
    	'post_parent' => $post->ID,
    	'exclude'     => get_post_thumbnail_id(),
    	'order'       => ASC,
    	'orderby'	  => menu_order,
    	'post_mime_type' => 'image',
    	'numberposts'	=> -1,
    );
    $attachment_page = get_attachment_link( $attachment_id );
    $attachments = get_posts($args);
    	if ($attachments) {
    		foreach ($attachments as $attachment) {
    			echo '<li>'.wp_get_attachment_image($attachment->ID, '').'</li>';
    		}
    	}
    ?>
    </ul>

    Thanks,
    Richard

  2. richgcook
    Member
    Posted 1 year ago #

    Choosing a size from the 'Add media' screen doesn't seem to do anything.

    [ Please do not bump, that's not permitted here. ]

Topic Closed

This topic has been closed to new replies.

About this Topic