[wp-hackers] Custom Post Types and Media Attachments

Hal Burgiss hal at burgiss.net
Fri Dec 10 22:43:13 UTC 2010


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.

-- 
Hal


More information about the wp-hackers mailing list