Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter B

    (@bh8489)

    I’ve found the following in wp-admin/includes/media.php, but I obviously don’t want to modify the core files, nor does this help with the database…

    function get_attachment_fields_to_edit($post, $errors = null) {
    	if ( is_int($post) )
    		$post =& get_post($post);
    	if ( is_array($post) )
    		$post = (object) $post;
    
    	$image_url = wp_get_attachment_url($post->ID);
    
    	$edit_post = sanitize_post($post, 'edit');
    
    	$form_fields = array(
    		'post_title'   => array(
    			'label'      => __('Title'),
    			'value'      => $edit_post->post_title
    		),
    		'image_alt'   => array(),
    		'post_excerpt' => array(
    			'label'      => __('Caption'),
    			'value'      => $edit_post->post_excerpt
    		),
    		'post_content' => array(
    			'label'      => __('Description'),
    			'value'      => $edit_post->post_content,
    			'input'      => 'textarea'
    		),
    		'url'          => array(
    			'label'      => __('Link URL'),
    			'input'      => 'html',
    			'html'       => image_link_input_fields($post, get_option('image_default_link_type')),
    			'helps'      => __('Enter a link URL or click above for presets.')
    		),
    		'menu_order'   => array(
    			'label'      => __('Order'),
    			'value'      => $edit_post->menu_order
    		),
    		'image_url'	=> array(
    			'label'      => __('File URL'),
    			'input'      => 'html',
    			'html'       => "<input type='text' class='text urlfield' readonly='readonly' name='attachments[$post->ID][url]' value='" . esc_attr($image_url) . "' /><br />",
    			'value'      => wp_get_attachment_url($post->ID),
    			'helps'      => __('Location of the uploaded file.')
    		)
    	);

    and

    function image_attachment_fields_to_edit($form_fields, $post) {
    	if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
    		$alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    		if ( empty($alt) )
    			$alt = '';
    
    		$form_fields['post_title']['required'] = true;
    
    		$form_fields['image_alt'] = array(
    			'value' => $alt,
    			'label' => __('Alternate Text'),
    			'helps' => __('Alt text for the image, e.g. “The Mona Lisa”')
    		);
    
    		$form_fields['align'] = array(
    			'label' => __('Alignment'),
    			'input' => 'html',
    			'html'  => image_align_input_fields($post, get_option('image_default_align')),
    		);
    
    		$form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size', 'medium') );
    
    	} else {
    		unset( $form_fields['image_alt'] );
    	}
    	return $form_fields;
    }
    Thread Starter B

    (@bh8489)

    I realized I should say more explicitly what I’m trying to do. I want to make photo credits easy. Ideally a drop down of users for each photo that allows changing of the photo creator.

    Thread Starter B

    (@bh8489)

    Nevermind, I got it. attachment_fields_to_edit and attachment_fields_to_save.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Attachment "Metadata"’ is closed to new replies.