I have a small problem with a custom loop in WordPress. I'm using the royal slider (normal jquery version) and want to display the attached images of a post as a slider.
So far, it works with this code:
<?php
$args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'order' => 'ASC', 'post_status' =>'any', 'post_parent' => $post->ID );
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ):
echo '<div class="rsContent">';
echo wp_get_attachment_image($attachment->ID, 'large', array( 'class' => 'rsImg'));
$description = $attachment->post_content;
if ($description):
echo '<div class="infoBlock infoBlockLeftBlack rsABlock" data-fade-effect="" data-move-offset="10" data-move-effect="bottom" data-speed="200">';
echo $description;
echo '</div>';
endif;
echo '</div>';
endforeach;
}
?>
So I get the attached images in fullsize. But now I like to get the attached images in medium and thumbnail size, too, so that I can create a responsive slider.
The way would be, that I can do a picture tag like this:
<picture>
<source srcset="Attachment Thumbnail size" media="(max-width: 400)">
<source srcset="Attachment Medium size" media="(max-width: 900)">
<source srcset="Attachment Full size">
<img srcset="Attachment Full size">
</picture>
Does anybody of you have a quick tip?
Thank you!
echo wp_get_attachment_url($attachment->ID, 'large', array( 'class' => 'rsImg'));makes no sense, since wp_get_attachment_url admits only id. I think you confused it with wp_get_attachment_image - dingo_d