Make WordPress Core

Opened 9 months ago

Last modified 3 months ago

#59308 new defect (bug)

Attachment custom fields not rendered in some cases

Reported by: sebsz's profile SeBsZ Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 6.3.1
Component: Media Keywords:
Focuses: javascript Cc:


This is a follow-up to #58051.

I've noticed that in some cases custom fields added via attachment_fields_to_edit do not show up when the "Featured Image" modal is opened after clicking a "featured image". I then need to first click on another attachment and then back to have the custom fields show up.

It seems that this bug only happens when you have a lot of images (more than 1 page) and the featured image you're looking at is not on the first page. It's easy to reproduce.

If absolutely necessary I can set up a clean WordPress and make a screen recording of this bug, as I rather not share the images and data in our WordPress installation.

Change History (9)

#1 @archon810
9 months ago

This is quite an annoying bug that is probably easy to fix because it's just a corner case of something that already works correctly.

This ticket was mentioned in Slack in #core-media by joedolson. View the logs.

8 months ago

#3 @SeBsZ
8 months ago

@antpb I managed to make a video for you which you requested. I'm running the latest nightly version of WordPress, which you can see in the video. It's a clean install. I activated the Twenty Twenty-Two theme and uploaded about 150 stock images to the media library. I then set one of the images to be the featured image for the default Hello World post. I picked the last image in the media library (not on the first page).

I added very little custom code to the theme's function.php, which I pasted below. Notably I had to disable the block editor since we don't use it. Interestingly, with the block editor enabled the bug does NOT occur!

add_filter('use_block_editor_for_post', '__return_false');

 * Add some custom fields to attachment edit page.

    function ($form_fields, $post) {
        $form_fields['extra_field'] = array(
            'label' => 'Extra field',
            'input' => 'html',
            'html'  => '<input type="text" class="text" readonly="readonly" value="' . \esc_attr(\get_the_title($post->ID)) . '" />',

        return $form_fields;

Video showing bug without block editor:!AtabcxrS-Zu3l64cKFmTKdp5ikwqqg?e=r8xK6u
Video showing no bug with block editor:!AtabcxrS-Zu3l64j3UQFux6yceADfQ?e=REOcnC

Please let me know if more information is needed!

This ticket was mentioned in Slack in #core-media by archon810. View the logs.

7 months ago

This ticket was mentioned in Slack in #core-media by antpb. View the logs.

7 months ago

#6 @SeBsZ
7 months ago

Any update here?

#7 @antpb
7 months ago

  • Milestone changed from Awaiting Review to 6.5

No update as I have not had time to investigate further. Moving to the 6.5 milestone for investigation during the next release cycle.

This ticket was mentioned in Slack in #core-media by antpb. View the logs.

3 months ago

#9 @antpb
3 months ago

  • Milestone changed from 6.5 to Future Release

Thank you so much for that testing @SeBsZ with the current workload ahead of me I'm going to need to deprioritize this one personally. With that in mind currently there is no one that can take it across the line so I am going to move this ticket to future release. Thats not to say that we would not merge a patch that fixes it if someone found a fix.

I invite anyone else to jump in on this and find a patch. I would be happy to review it!

Note: See TracTickets for help on using tickets.