Last active
August 29, 2015 14:26
-
-
Save taniarascia/1ac171eaf23439f78941 to your computer and use it in GitHub Desktop.
Force uploaded media to create a certain thumbnail size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add 250 x 250 thumbnail to every image uploaded | |
add_image_size( 'gallery-thumbnail', 250, 250, true ); | |
// gallery_thumbnail is a custom size! It can have any name. | |
// Call it later in a gallery loop. | |
<section id="gallery_page"> | |
<ul class="gal columns-4"> | |
<?php | |
$args = array( | |
'post_type' => 'attachment', | |
'post_mime_type' => 'image', | |
'orderby' => 'post_date', | |
'order' => 'desc', | |
'posts_per_page' => '50', | |
'post_status' => 'inherit', | |
'category_name' => 'Gallery Page' | |
); | |
$loop = new WP_Query( $args ); | |
while ( $loop->have_posts() ) : $loop->the_post(); | |
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'gallery-thumbnail' ); | |
$url = $thumb['0']; | |
$image = wp_get_attachment_image_src( get_the_ID() ); | |
echo "<li><img src='" . $thumb[0] . "'></li>"; | |
endwhile; ?> | |
</ul> | |
</section> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment