Home › Forums › General Issues › Recreating fancybox effect with image ID › Reply To: Recreating fancybox effect with image ID
Hi Elliot,
Actually, I realised that I don’t need to work with “ID” at all. Instead, I can use “Object” type and still have a custom size as a thumbnail.
So what I do now is have a function like this:
/**
* Add automatic image sizes
*/
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'smallsquare', 45, 45, false ); //false: soft prop crop, true: hard crop
}
which creates ‘smallsquare’.
So I can use ‘smallsquare’ with Object and get done what I wanted like this:
<a href="<?php the_field('race_website') ?>" target=_new>
<img class="race_wiki_img" alt="" src="<?php $image = get_field('race_logo'); echo($image['sizes']['smallsquare']); ?>" />
</a>
A very friendly suggestion, perhaps make this clearer in the docs for future users? The way it is written I got the idea that only predefined sizes can be used with Object, but if you want custom sizes you need to use ID.
Thanks for the help
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.