WordPress.org

Ready to get started?Download WordPress

Forums

attachment_fields_to_edit not working with WP 3.5 (4 posts)

  1. BastianG
    Member
    Posted 1 year ago #

    Hi,

    I had in my functions.php a small helper function working on the filter attachment_fields_to_edit which just fills some fields during media upload:

    function add_image_attachment_fields_to_edit( $form_fields, $post ) {
        //$form_fields['post_content']['value'] = 'my-value';//Description
    	$img_title = get_the_title($post->ID);
    	$post_title = get_the_title($post->post_parent);
    	$img_exif = get_wp_exif_tags($post->ID);
    	if ($img_title <> ''){$post_title = $post_title .' - ' . $img_title;}
    	if ($img_exif == ' , ') {$img_exif = '';} else {
    			if ($post_title <> 'Auto Draft') {$img_exif = ' | ' . $img_exif;}
    				else {$post_title = '';}
    			}
        $form_fields['image_alt']['value'] = $post_title . $img_exif;
        //$form_fields['post_excerpt']['value'] = 'my-value'; //caption
        //$form_fields['url']['value'] = 'my-value';
        return $form_fields;
    }
    add_filter("attachment_fields_to_edit", "add_image_attachment_fields_to_edit", 15, 2);

    But somehow this is not throwing any error message nor it is working - do you have any idea what might causing this not working?

    Thanks, Sebastian

  2. JFrankParnell
    Member
    Posted 1 year ago #

    Not working for me, either. I am doing sth different with the filter than you, but I dont get an error, and if I print_r with the $form_feilds, the screen stops working and just shows blank empty space.

  3. gumbah
    Member
    Posted 1 year ago #

    Same problem here... :-(

  4. Andrew
    Forum Moderator
    Posted 1 year ago #

    Gumbah & JFrankParnell, create your own threads if you require support. Posting me-too comments doesn't contribute to the original poster's issue.

Topic Closed

This topic has been closed to new replies.

About this Topic