[wp-trac] [WordPress Trac] #59308: Attachment custom fields not rendered in some cases
WordPress Trac
noreply at wordpress.org
Mon Oct 9 12:33:00 UTC 2023
#59308: Attachment custom fields not rendered in some cases
--------------------------+------------------------------
Reporter: SeBsZ | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 6.3.1
Severity: normal | Resolution:
Keywords: | Focuses: javascript
--------------------------+------------------------------
Comment (by SeBsZ):
@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!
{{{#!php
add_filter('use_block_editor_for_post', '__return_false');
/**
* Add some custom fields to attachment edit page.
*/
\add_filter(
'attachment_fields_to_edit',
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;
},
10,
2
);
}}}
Video showing bug without block editor: https://1drv.ms/v/s!AtabcxrS-
Zu3l64cKFmTKdp5ikwqqg?e=r8xK6u
Video showing no bug with block editor: https://1drv.ms/v/s!AtabcxrS-
Zu3l64j3UQFux6yceADfQ?e=REOcnC
Please let me know if more information is needed!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59308#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list