Home › Forums › Front-end Issues › Image array won\'t output custom image sizes
Hi Folks,
I’ve been using ACF for awhile and I haven’t seen this error before.
There’s an image field registered in a repeater that I’m trying to output custom thumbnail sizes for.
Here’s a simplified version of the code I’m using to call the thumbnail size. The image is set to ‘Image array’ in ACF (and yes, the thumbnail size has been registered and those sizes all exist. I already double checked that one):
<img src="<?php echo $image['sizes']['thumb-small']; ?>" />
Here are the ACF settings for the field:
I then troubleshot the image by checking its variables, and that’s when things got interesting. I printed out all the thumbnails…and they all link to the same image. So even though the thumbnails exist in the correct sizes in the WP uploads folder, ACF isn’t linking to them. Here’s the first portion of the code:
Array
(
[ID] => 1411
[id] => 1411
[title] => services_banner
[filename] => services_banner.png
[url] => https://192.168.0.25/3degrees/wp-content/uploads/2015/12/services_banner.png
[alt] => Services Alt text
[author] => 4
[description] =>
[caption] =>
[name] => services_banner
[date] => 2016-03-13 02:57:20
[modified] => 2017-10-19 21:47:19
[mime_type] => image/png
[type] => image
[icon] => https://192.168.0.25/3degrees/wp-includes/images/media/default.png
[width] => 0
[height] => 0
[sizes] => Array
(
[thumbnail] => https://192.168.0.25/3degrees/wp-content/uploads/2015/12/services_banner.png
[thumbnail-width] => 1
[thumbnail-height] => 1
[medium] => https://192.168.0.25/3degrees/wp-content/uploads/2015/12/services_banner.png
[medium-width] => 1
[medium-height] => 1
[medium_large] => https://192.168.0.25/3degrees/wp-content/uploads/2015/12/services_banner.png
[medium_large-width] => 1
[medium_large-height] => 1
[large] => https://192.168.0.25/3degrees/wp-content/uploads/2015/12/services_banner.png
[large-width] => 1
[large-height] => 1
[thumb-small] => https://192.168.0.25/3degrees/wp-content/uploads/2015/12/services_banner.png
[thumb-small-width] => 1
[thumb-small-height] => 1
[thumb-med] => https://192.168.0.25/3degrees/wp-content/uploads/2015/12/services_banner.png
[thumb-med-width] => 1
[thumb-med-height] => 1
[thumb-large] => https://192.168.0.25/3degrees/wp-content/uploads/2015/12/services_banner.png
[thumb-large-width] => 1
[thumb-large-height] => 1
...
Has anyone ever seen anything like this? Any solutions recommended?
Thanks,
Adam
HI @pixelsmith
I ran into the issue before (more than once)… where WP was creating 1×1 images for all image sizes. I guess… since they are all the same size, they all have the same URL? (I can’t be sure on that though).
At any rate… one time… it was a plugin that was creating 1×1 images for all sizes.. like: add_image_size( ‘thumb-1’, 1, 1, true )
…another time it was image compression software (like WP Smush IT, Shortpixel, Photon) that was messing with image sizes that caused it. I can’t remember the image compression software now (it wasn’t any of the ones listed above tho).
To fix… I removed the tools… regenerated thumbs, and all was good.
So… not sure if it’s an ACF issue… it might have happened within the Media Library during upload by some other hook.
Hope you are able to sort it out, and it’s a simple fix!
Hey @keithlock – Thanks for the suggestions.
I was able to fix the issue by uploading a new image. New images worked just fine, but when I changed images (chose new image, reverted to original image) I ran into the same issue.
I wish I could solve the issue itself, since there are at least a dozen images I’ll have to change, but at this point I’m glad to have any solution.
Best,
Adam
Hi
Can you please share any news on this issue?
Same issue here. While uploading images with Media Library it sets the right links for the custom image sizes in $image['sizes']
. But if I upload the image with one of the ACF image fields it sets the actual size image url for all the elements in the $image['sizes']
array.
You must be logged in to reply to this topic.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.