I am using this code to get all posts attachment which it is doing fine.
My problem is I am not getting the desired attachment size. When I don’t specify the size with “the_attachment_link($attachment->ID);” I get the thumbnail and when I try by adding “medium, small, large, or full” I get the full size only.
Am I missing something here? I need some support please.
$args = array(
'post_type' => 'attachment',
'numberposts' => null,
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
echo apply_filters('the_title', $attachment->post_title);
the_attachment_link($attachment->ID, 'medium', true);
}
}
Hi try something like this:
make use of the $src[0].
set the height and width according to your preference.
hope this solves it.