Support

Account

Home Forums General Issues Image['sizes']['sqr_crop'] returns different url in my local and hosted page

Solved

Image['sizes']['sqr_crop'] returns different url in my local and hosted page

  • hello

    I’ve been having some trouble with how the plugin handles links in my online page and in my local page. When I use the plugin locally the url is somthing like “/wp-content/uploads/2021/06/generic_image-500×500.png” and when is in the online version the url is “/wp-content/uploads/2021/06/no-profile-picture_3.png?resize=500%2C500&ssl=1”, I need the url for the online page to match the local. how could I achive that?? my code is
    src="<?php $img_f = get_field('image'); echo $img_f['sizes']['sqr_crop']?>" alt="">

  • There is something not matched up on the two. Either the image is missing or the attachment ID is wrong on the site. Check the image field to make sure the right image is being used.

  • I’ve checked the files… is not that, both the original image and the crop image are in my files, how do I check the attachment id?

  • It has nothing to do with the files existing.

    ACF stores and attachment ID (post ID) in the database for the image field. It gets and returns the image that is associated with that ID. The code that you provided indicates that instead of the correct image that the site is showing some default image ...no-profile-picture_3.png.... This means that the image ID stored by ACF, if there is an image ID stored by ACF is incorrect. This can be checked by going to the page/post/user where this image is set and seeing if the correct image is shown.

    I am just guessing that the ID is wrong based on what you have provided.

  • How did the content get from your dev site to the live site? Did you use the standard WP import? If this is the case then when images were imported the ID values would not be the same on each site so every image could potentially have the wrong ID stored by ACF.

  • nop I had to import some custom crops so I uploaded them to the files manager, guess that broke the id system, erasing and uploading again fixed the problem

  • can I unsolve it… it happened again… and this time with a new image that I only added in the online page…

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.