Hello!
In version 1.0.2 we changed the upload field from storing the url to the file into storing the attachment ID for the file.
So now you can use functions like wp_get_attachment_image, wp_get_attachment_image_src or wp_get_attachment_url depending on the desired functionality
hi is it possible you can state the code/syntax for the function to display the image – wp_get_attachment_image, wp_get_attachment_image_src or wp_get_attachment_url to actually display the link (sorry…. just starting out in php)
I received your reply via email but is not listed here in WordPress support
Thanks
Hi, love your plugin.
Cant put images working, who do I set the code for wp_get_attachment_image on version 1.0.3? can you explane the code?
Thanks
I’m having the same issue. The plugin is great indeed but could you give a full code example of getting the image with version 1.0.3 upwards. If we take a simple use case:
foreach($items as $item){
echo ‘<img src=”‘.$item[‘item_pic’].'” />’;
}
What would be the code equivalent in the newer version?
Many thanks.
Hey Pedromrferreira,
I’ve been looking into this and i have a solution for you. Please see below. Hopefully this will help others out since the change in the plugin’s way of accessing images. The exampel below is something i’ve worked up which loops through all images in a repeater and outputs both a thumbnail and full size image so you can pick from what you want. If you have other sizes specified in Worpdress you can just replace ‘full’ with your named image size:
<?php
$clientimages = get_post_meta( $post->ID, ‘clients’, true );
foreach($clientimages as $clientimage){ // For each loop for
$thumbnail = wp_get_attachment_image_src( $clientimage[‘clientimage’] );
$full = wp_get_attachment_image_src( $clientimage[‘clientimage’],’full’ );
echo ‘<img src=”‘ . $thumbnail[0] . ‘” />’;
echo ‘<img src=”‘ . $full[0] . ‘” />’;
}
?>
OK, got it:
<?php
$actividades = get_post_meta( $post->ID, 'actividades', true );
echo '<ul class="content-act">';
foreach( $actividades as $actividade){
echo '
<li>';
echo '<h2>' . $actividade['titulo'] . '</h2>';
$attachment_image = wp_get_attachment_image_src($actividade['imagem'], 'full');
echo '<img src="'. $attachment_image[0].'" width="<'. $attachment_image[1] .'" height="'. $attachment_image[2] .'"/>';
echo '<p>' . $actividade['descricao'] . '</p>';
echo '</li>
';
}
echo '';
?>
Use This: Had same problem… It worked for me…
$result = wp_get_attachment_image_src($addbooks['book-image']);
$url = $result[0];
echo '<img src="'. $url.'" >';
where,
‘$addbooks’ : name of metabox.
‘book-image’ : name of image field.
It will show image in thumbnail for showing full image. USe:
$result = wp_get_attachment_image_src($addbooks['book-image'],'full');
Hope it will help you…
Happy Coding…!!! -TK