Hi.
How would I repeat images from a field and wrap them in custom tags. I want to use a basic jquery slider and I just need to echo out each image url but put my own htlm before and after each one.
Many thanks
Hi sams-3,
I assume your repeat image field is created by Types, using slug "my-images",
Please try this:
$slug = 'my-images';
$size = 'thumbnail';
$meta = 'url';
global $wpcf;
$my_field = new WPCF_Repeater();
$my_field->set(get_the_ID(), wpcf_admin_fields_get_field($slug));
$get_meta = $my_field->_get_meta();
$arr = array();
if(isset($get_meta['custom_order']))
{
$arr = $get_meta['custom_order'];
}
foreach($arr as $k=>$v)
{
$field = wpcf_fields_get_field_by_slug( $slug );
$params = array("alt" => "", "title" => "", "width" => "80", "height" => "80", "proportional" => "true", "url" => "true");
$params['field_value'] = $v;
$thumbnail = types_render_field_single($field, $params, null, '', $k);
$params['size'] = 'full';
$fullsize = types_render_field_single($field, $params, null, '', $k);
$res .= '<a href="' . $fullsize . '"><img src="' . $thumbnail . '"></a>';
}
echo $res;
it will return such a html:
<a href="' . $fullsize1 . '"><img src="' . $thumbnail1 . '"></a>
<a href="' . $fullsize2 . '"><img src="' . $thumbnail2 . '"></a>
<a href="' . $fullsize3 . '"><img src="' . $thumbnail3 . '"></a>
Thank you so much. Even though that is a lot of code his works perfectly.
Kudos for you sir
Well, your code works, but it doesn't show thumbnails as expected. Can someone verify that thumbs are in fact showing?
Sorry, should have clarified, this code DOES show an image, but only the full size, instead of a thumb. Link to full size works as expected though.
Yes, I have the same issue. Shows my images just fine, but only shows the full size, even when I specify "thumbnail".. Is there a fix for this?
(also, I am using this plugin, https://wordpress.org/plugins/wpro/), which posts media to S3 without writing to the local server. I am testing this on my localhost
Essentially I want
<a href="LINK TO FULL IMG"><img src="THUMBNAIL" SIZE TO BE MY THUMBNAIL SETTING></a>
Where are you supposed to place this code? When I add this to a Custom View it does nothing except except place a few line breaks and output some of the code onto the page. I'm guessing this has to go somewhere else besides your View template?
You would place this code in a template file, such as header.php or page.php.
It is for hard coding into your theme, rather than using in a page content area.
I'm having the same issue as mayurJ, Types is not outputting the thumbnails, only full size images. Is this not possible with Types? I'm also getting this php notice:
Notice: Trying to get property of non-object in [...]/plugins/types/embedded/views/image.php on line 815
Shawn, are you running this on your local machine or a development URL? I have had some issues in the past with using this when developing on the server address, like hidden link, rather than the domain
@sams-3:
Both. I have a localhost site and a staging site online. The staging site has errors turned off so you don't see the notice but the output in the html is the same.
I started another thread here: https://toolset.com/forums/topic/getting-a-list-of-images-in-2-sizes-from-repeating-field/#post-293700