[wp-hackers] Custom Post Types and Media Attachments

Malte Witt m.witt at ia-sh.de
Sat Dec 11 13:59:36 UTC 2010


As far as I can tell, the media-upload code gets the Post-ID by 
GET-Parameter when using a.) the standard wp editing frame b.) the 
editor from the custom field plugin. So for sure it has to get the post 
id that way. But wheter I call the media-upload code from standard 
editor or custom field plugin it get's the same GET parameters so the 
part, where it is told which specific part of the page the image has to 
be inserted to, must be handled somewhere in JS.

I would be really interested to know how this works.


Am 10.12.2010 23:43, schrieb Hal Burgiss:
> On Fri, Dec 10, 2010 at 10:31 AM, Becky Resler<becky.absolute at gmail.com>wrote:
>
>> This screenshot shows what I get when I upload an image from the
>> *Products* meta box. As you can see, the *Insert into Post* button is
>> missing.
>>
> Not sure this is exactly the same issue, but a while back I ran into
> something similar, and it turned out the media-upload code was not getting
> the post_id value, and thus had no way to associate the upload with the post
> fully. Best I can tell, this value has to be set in the javascript. Once
> that was done both the Insert button showed up, and I had a correctly
> associated image, ie the attachment's parent value was set correctly. This
> was with a regular input with a file type and not a textarea, but sounds
> like similar enough symptoms. The little bit of javascript that worked for
> me, was adding the post_id to this statement:
>
>          tb_show('', 'media-upload.php?post_id=' + post_id +
> '&amp;type=image&amp;TB_iframe=true');
>
> The tutorial I first found, had left out that post_id part. Prior to this of
> course, the js post_id var would need to be set.
>



More information about the wp-hackers mailing list