/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* Could be nicer. It adds in the <UL> code before and after checking if there are attachements, * but I only want to filter if attachments are bigger than (SIZE), so it may add an <UL> for * attachments that do not meet minimum requirements. */ $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order') ); if ($attachments > 0) { echo '<ul class="post-images">'; } foreach ( $attachments as $attachment_id => $attachment ) { $attachment_meta = wp_get_attachment_metadata($attachment_id); if ($attachment_meta['width'] == 1280) { echo '<li>'; echo wp_get_attachment_image($attachment->ID, 'full'); echo '</li>'; //echo $attachment_meta['width']; } } if ($attachments > 0) { echo '</ul>'; }