When I check “view source > frame info” on the window produced by the jQuery code below, it cuts off the querystring at the &type=image. I’m url encoding the ampersands properly, right?
Address: ...wp-admin/media-upload.php?post_id=28&type=image&
function wpe_customImages($initcontext)
{
global $post;
?>
<script type="text/javascript">
jQuery(document).ready(function() {
var fileInput = '';
jQuery('#wpe-uploadAttachments').click(function() {
fileInput = jQuery(this).prev('input');
formfield = jQuery('#upload_image').attr('name');
post_id = jQuery('#post_ID').val();
tb_show('', 'media-upload.php?post_id='+post_id+'&type=image&TB_iframe=true&wpe_idCustomAttachment=true');
return false;
});
As you have asked wether or not you have done the url encoding for the ampersands right, then my answer is: No.
You are calling a javascript function, you’re not outputting something as x(ht)ml. You therefore do not need to encode
&
as&
. The function is expecting a URL not a string that contains an xml encoded url.But that’s probably nit-picking.
The reason why this does not work is, that tb_show() cut’s away anything after the first
TB_
it finds in that URL, and only the part of the URL before that string is preserved for the iframe src. So you need to move theTB_iframe=true
to the end of the parameter. This should do the trick:BTW, wordpress is open source. You can just look to find the tb_show() function in source and look why something is happening or not. This can help to find out specific stuff. I didn’t do anything else 🙂