WordPress.org

Making WordPress.org

Opened 3 years ago

Closed 21 months ago

#1746 closed defect (worksforme)

Filter attachment_fields_to_edit

Reported by: robertoentringer Owned by:
Milestone: Priority: lowest
Component: General Keywords: has-screenshots
Cc:

Description

Filter attachment_fields_to_edit display not necessary required field message.

Exemple :

add_filter('attachment_fields_to_edit', 'theme_attachment_fields_to_edit', 10, 2);

function theme_attachment_fields_to_edit($form_fields, $post) {
    $form_fields['theme-custom-attachment-field-url'] = array(
        'label' => __('Custom URL'),
        'input' => 'text',
        'required' => false,
        'value' => get_post_meta($post->ID, 'theme_custom_attachment_field_url', true),
        'helps' => '' //__('Enter the destination URL')
    );
    
    return $form_fields;
}

Source of the bug :

// wp-admin/includes/media.php lines 1743 to1749

if ( $item ) {
		$item = '<p class="media-types media-types-required-info">' .
			sprintf( __( 'Required fields are marked %s' ), '<span class="required">*</span>' ) . '</p>
			<table class="compat-attachment-fields">' . $item . '</table>';
	}

Attachments (1)

screenshot.png (25.1 KB) - added by robertoentringer 3 years ago.
screenshot

Download all attachments as: .zip

Change History (2)

@robertoentringer
3 years ago

screenshot

#1 @obenland
21 months ago

  • Resolution set to worksforme
  • Status changed from new to closed

Hm, I can't seem to find any reference to theme_attachment_fields_to_edit anywhere. This was probably removed with the switch to the new Theme Directory.

Note: See TracTickets for help on using tickets.