Reputation: 2958
I have this function which takes postID and returns post's thumbnail
function stack_309224_attachhment($atts){
extract(shortcode_atts( array(
'id' => 1, // default id of the post
"max" =>4 ,// default max number of images to display
"featured"=>"false" // if to retrieve the post featured image or not, default false
), $atts ));
ob_start();
if($atts['featured']=="true"){ // display only the featured image get_the_post_thumbnail get_post_thumbnail_id
?>
<figure><img src="<?php echo wp_get_attachment_image_src(get_post_thumbnail_id( (int)$atts['id']) )[0]?>" /></figure>
<?php
}
else{ // display a gallery of attached images within "max" attr.
$images=get_attached_media( 'image', (int)$atts['id'] );
if(count($images) > 0 ){
?>
<div class="gallery">
<?php
$index=0;
foreach($images as $image){
if($index < (int)$atts['max']){ //display image only if within max
?>
<figure><img src="<?php echo wp_get_attachment_url($image->ID)?>" /></figure>
<?php
$index ++;
}
}
?></div><?php
}
}
return ob_get_clean();
}
But the problem is it's returning me the smallest size of thumbnail ex."http://Mysite/my_image_n-150x150.jpg"
how can i get the full size of image? ex. "http://Mysite/my_image_n.jpg"
Upvotes: 1
Views: 2901
Reputation: 99
You can use this function
<?php
$src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full', false );
'full' is a size of image
In your case, you can change to
<figure><img src="<?php echo wp_get_attachment_image_src(get_post_thumbnail_id( (int)$atts['id']), 'full', false )[0]?>" /></figure>
Upvotes: 1