asset-manager-framework icon indicating copy to clipboard operation
asset-manager-framework copied to clipboard

Currently selected featured image gets duplicated in amf generated media library

Open shubham-grazitti opened this issue 2 years ago • 1 comments

I encountered an issue while trying to replace a featured image in WordPress. When I navigate to the media library generated by AMF, and select a new image, the current featured image gets added/duplicated to the AMF media library.

Steps to Reproduce:

  1. Add a featured image to a post (it could be from the local library or the AMF-generated library).
  2. Click on the "Replace" Featured Image button.
  3. Navigate to the AMF-generated media library.
  4. Select a new image from the library.

I am assuming this is related to Wordpress as I can see js events are generating the li item(currently selected featured image item) to the library are written in Wordpress.

Is there any way I can fix this?

I have tried resetting the current selection when the media dialog is opened, but it doesn't seem to work

wp.media.featuredImage.frame().on('open', function() {
      const frame = wp.media.featuredImage.frame();
      const selection = frame.state().get('selection');
      selection.reset();
    });

shubham-grazitti avatar May 16 '23 06:05 shubham-grazitti

Seems to not be limited to the featured image UI but the media replace workflow in general. It's failing to find the existing post by name or ID for some reason. Definitely a bug to address in this plugin.

roborourke avatar Jan 19 '24 18:01 roborourke