[wp-hackers] Populating Image meta box fields on new image upload

Les Bessant les at lcb.me.uk
Tue Jul 12 07:46:36 UTC 2011


Worked in 3.1.x, still works in 3.2

--
Les Bessant les at lcb.me.uk
Losing it[1] - http://losingit.me.uk/
My flickr pictures - http://flickr.com/photos/lesbessant/



On 11 Jul 2011, at 22:18, Peter Adams wrote:

> in what version? 3.1.4?
> 
> On Jul 9, 2011, at 11:42 PM, Les Bessant wrote:
> 
>> Is this any help? It's some code I found somewhere and adapted to put the EXIF title in all three text boxes on the image upload page:
>> 
>> add_filter('attachment_fields_to_edit', 'image_caption_to_title', 11, 2 );
>> 
>> function image_caption_to_title( $form_fields, $post ) {
>> 	if ( substr( $post->post_mime_type, 0, 5 ) == 'image' ) {
>> 		$form_fields['post_excerpt']['value'] = $post->post_title;
>> 		$form_fields['image_alt']['value'] = $post->post_title;
>> 	}
>> 	return $form_fields;
>> 	}
>> 
>> Works for me, anyway
>> 
>> --
>> Les Bessant les at lcb.me.uk
>> Losing it[1] - http://losingit.me.uk/
>> My flickr pictures - http://flickr.com/photos/lesbessant/
>> 
>> 
>> 
>> On 10 Jul 2011, at 04:28, Peter Adams wrote:
>> 
>>> ok, getting a little closer. I'm now using the attachment_fields_to_edit hook to populate the empty form fields on the attachment meta screen but i can't populate the "Alternate text" field. 
>>> 
>>> I see it in the $form_fields array that is passed into the hook but any label or value I set on it does not show up on the form.
>>> 
>>> any ideas?
>>> 
>>> -P-
>>> 
>>> 
>>> 
>>> On Jul 9, 2011, at 3:04 AM, Charles Frees-Melvin wrote:
>>> 
>>>> They are the title and the_content of the attachment:image post-type.
>>>> 
>>>> --
>>>> Charles E. Frees-Melvin
>>>> 
>>>> Sent from my Rogers iPhone 3G
>>>> 
>>>> On 2011-07-09, at 6:55, Peter Adams <peter at oncefuture.com> wrote:
>>>> 
>>>>> Hi folks -
>>>>> 
>>>>> I  can't figure out how to populate the fields on the image meta box. I see that the title, and description are populated from the image's EXIF fields, but they are not stored in the attachment meta so there for i can't use wp_generate_attachment_meta filter to populate/change them.
>>>>> 
>>>>> Where are they stored?
>>>>> 
>>>>> I'd like to filter the values before they are populated in the image meta box upon new image upload.
>>>>> 
>>>>> Thanks,
>>>>> 
>>>>> -P-
>>>>> 
>>>>> _______________________________________________
>>>>> wp-hackers mailing list
>>>>> wp-hackers at lists.automattic.com
>>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>> _______________________________________________
>>>> wp-hackers mailing list
>>>> wp-hackers at lists.automattic.com
>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>> 
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>> 
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
> 
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list