• Resolved cjyabraham

    (@cjyabraham)


    I am using the following image control:

    
    array(
    'type'            => 'image', // Required.
    // Optionally, an id may be specified. It will be used by the plugin to
    // identify the setting and will be applied to the control html.
    // The prefix set in the sidebar option 'id_prefix' will be applied.
    'id'              => 'favicon',
    'data_type'       => 'meta', // Available: 'meta', 'localstorage', 'none'.
    'data_key'        => 'favicon', // Required if 'data_type' is 'meta' or 'localstorage'.
    // Use 'data_key_prefix' to set a custom prefix for this setting 'data_key'.
    // If 'data_key_prefix' is not assigned, the 'data_key_prefix' from the sidebar
    // where this setting is nested will be used.
    'label'           => __( 'Favicon', 'my_plugin' ),
    'help'            => __( 'Should be a 32x32 png file. Use realfavicongenerator.net.' ),
    'register_meta'   => true, // This option is applicable only if 'data_type' is 'meta'.
    'ui_border_top'   => true, // Display CSS border-top in the editor control.
    ),
    

    When I set an image it shows the image correctly, however, after I reload the edit screen and view the setting it shows this. The meta value is definitely there in the db and I can use it on the front-end, but why doesn’t it show the image correctly in the admin. This works fine for other images I upload to similar meta settings, it’s just this one that seems to do this. Does it have something to do with the size of the favicon image that I upload? Any ideas?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Alvaro

    (@melonpan)

    Hi,

    This message is shown when an image id was saved, but it is no longer found in the Media library.

    This happens when an image id is saved to the meta, but later this image is removed from the Media library. The plugin will look for the id using the REST API and, as there is nothing returned, it will show the message. It could also happen if for other reasons the REST API is not returning the value correctly.

    Could this be your case, that the image was removed? Check this REST route to see if it returns the image correctly:

    https://yoursite.com/wp-json/wp/v2/media/2454

    It should show the image JSON data or, if not found, rest_post_invalid_id JSON.

    Thread Starter cjyabraham

    (@cjyabraham)

    Thanks for the quick response.

    I did a bit more testing and it appears to only fail like this for the favicons we are using. The REST route for them still appears fine however.

    You can try the problematic favicons here and here if you want to try and reproduce. All other images work.

    Plugin Author Alvaro

    (@melonpan)

    I just tested it and it does as you describe. It’s a strange thing because it actually returns the data correctly, but immediately after changing the state it throws the error.

    I’ll look closer into it tomorrow and let you know.

    Thread Starter cjyabraham

    (@cjyabraham)

    Great. Thanks.

    Plugin Author Alvaro

    (@melonpan)

    I found the issue. When the image is very small, there are no “sizes” in the media_details property of the REST response.

    I already commited the fix and I’ll upload a new version tomorrow. I’ll close this issue for now.

    Thanks

    Plugin Author Alvaro

    (@melonpan)

    Just published version 1.3.1 which fixes this issue. Let me know otherwise. Thanks

    Thread Starter cjyabraham

    (@cjyabraham)

    LGTM. Thanks for the quick fix!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘“Image with id was not found”?’ is closed to new replies.