Hi,
All image upload fields use WordPress image sizes, which are registered by theme or plugins.
When you display images in the frontend, don’t get the “full” size. Instead, you just need to specify a param size=$size_name (where $size_name is an image size which is registered before with add_image_size function) and you will get a smaller version, like this:
$images = rwmb_meta( 'gallery', 'type=image&size=YOURSIZE' );
foreach ( $images as $image )
{
echo "<a href='{$image['full_url']}' title='{$image['title']}' rel='thickbox'><img src='{$image['url']}' width='{$image['width']}' height='{$image['height']}' alt='{$image['alt']}' /></a>";
}
Best regards
Brilliant, thank you, I really appreciate that.
When I add:
add_image_size( 'flexslider-thumb', 167, 119 );
add_image_size( 'flexslider-main', 757, 454 );
To functions.php, then use those size names in the flexslider code like this:
$images = rwmb_meta( 'swso_prodImage', 'type=image&size=flexslider-main');
foreach ( $images as $image )
{
echo "<li><a href='{$image['full_url']}' title='{$image['title']}' rel='thickbox''><img src='{$image['url']}' width='{$image['width']}' height='{$image['height']}' alt='{$image['alt']}' /></a></li>";
}
Then re-upload the images, it all works fine.
I do have another question though. The link to the full size image adds “/undefined” to the current page URL rather than actually linking to the full size image. Any ideas what could be causing this?
That sounds strange to me. I haven’t seen that problem. The function that gets full URL only uses WP function wp_get_attachment_url, which shouldn’t return any “undefined” string.
Maybe you should try regenerate thumbnails? Or do you have any plugins/settings related to the attachment?
It could well be related to flexslider. I’ll look at that, thanks again.