Support

Account

Home Forums ACF PRO Can't add image if it does not exist in specified preview size

Solving

Can't add image if it does not exist in specified preview size

  • I have experienced an issue with images not being added, when the selected image does not exist in the specified preview size. (The most common examples are images that are smaller than the specified preview size.)

    It seems to be line 120 in image.js:

    
    // override url
    if( acf.isset(attachment, 'attributes', 'sizes', this.settings.preview_size, 'url') ) {
      attachment.url = attachment.attributes.sizes[ this.settings.preview_size ].url;
    }
    

    This should have a fallback to the default image url in case the preview size does not exist

    I’ve made it work with the following (they might be a more pretty way):

    
    // override url
    if( acf.isset(attachment, 'attributes', 'sizes', this.settings.preview_size, 'url') ) {
      attachment.url = attachment.attributes.sizes[ this.settings.preview_size ].url;
    }
    // set to default url in case preview size does not exist 
    else if(acf.isset(attachment, 'attributes', 'url')){
      attachment.url = attachment.attributes.url;
    }
    
  • Hi @andersthorborg

    Thanks for the bug report. I believe this issue has already been fixed (about a day after initially released). Firstly, can you please download the latest version of ACF PRO and copy over the js folder.

    Thanks
    E

  • Hi Elliot,

    Strange. For me this is the case in 5.0.8 – on multiple installations.

    Thank you for the quick response.

    Best,

    Anders

  • Hi @andersthorborg

    Can you please re-download the latest version of ACF PRO and test it out?

    Thanks
    E

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

The topic ‘Can't add image if it does not exist in specified preview size’ is closed to new replies.