I'm grabbing URLs of my Gallery images:
$gallery = get_post_gallery_images( $post );
foreach($gallery as $thumbnail) {
echo $thumbnail_slideshow;
}
The problem is all I'm getting are thumbnails:
image1-150x150.jpg
image2-150x150.jpg
image3-150x150.jpg
And I want to get:
image1-600x100.jpg
image2-600x100.jpg
image3-600x100.jpg
Of course I have my custom image_size defined in functions.php:
add_image_size( 'mysize', 660, 100, true );
And I'm wondering if it is possible to do the easy way using get_post_gallery( $post )
or should create some kind of a loop?
Here's a great answer by Otto, unfortunately it doesn't work for me (I'm trying to make it work in single-customposttype.php, it displays nothing, replacing $post->ID
with $page->ID
or $parent->ID
displays EVERYTHING from Media Library ).
UPDATE
Looks like I don't understand something right.
I took a snippet I've seen around in many places, also in Otto's post above:
$gallery_images = new WP_Query(array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
));
while ( $gallery_images->have_posts() ) : $gallery_images->the_post();
the_title();
the_content();
the_permalink();
endwhile;
I pasted it into content.php of Twenty Thirteen and guess what? It returns NOTHING, and of course this post HAS gallery and get_post_gallery_images($post) work on it flawlessly. What am I doing wrong?
Of course when I UPLOAD image to the gallery code above works, because the image is uploaded / attached directly to this post. All of my other images are of course "(Unattached)" and this might be a problem...
UPDATE II
Got it, finally. Looks like Gallery images used to be attached to posts in WP pre-3.5, now it doesn't work this way. Here's it well explained. So the question is - is this solution good and is it safe to use it for the future? Of maybe it's possible to play with get_post_gallery_images sizes? To be honest this function would be so much more powerful if it would load all image sizes in multidimensional array...