Hot answers tagged

9

All you need to do is a simple call in your functions.php: add_action( 'wp_enqueue_scripts', 'add_thickbox' ); That’s it. WordPress will now enqueue jQuery and the thickbox script. By default, linked images aren’t thickboxy yet. You need to: Add a class thickbox to the links manually/per PHP, or Use a second script to add these classes automagically. ...


6

The second parameter for tb_show is the URL, so you'll want to use something like.. <?php $ajax_url = add_query_arg( array( 'action' => 'getTheContent', 'query_var1' => 'value1', 'query_var2' => 'value2' ), admin_url( 'admin-ajax.php' ) ); ?> tb_show(tag, <?php echo $ajax_url; ?> ); I'd ...


5

Tricky but once you understand how WordPress sets the sizes and the fields then the rest is easy: function thickbox_fields($form_fields, $post){ unset( $form_fields['post_title'], //disables "Title" field and so forth... $form_fields['url'], $form_fields['image_alt'], $form_fields['post_excerpt'], ...


5

The following works for me for product archive pages (these include both the main shop page as well as archive pages for product categories, for example). It will show the current cart contents in a thickbox. I chose to show this for this example just because that's the data that one gets back through Ajax after clicking the add-to-cart button, but you may ...


4

When the thickbox gets closed it triggers 'tb_unload' (in earlier Wordpress version it was just 'unload' (not sure though) ) so you can do something like: $(window).bind('tb_unload', function() { //do stuff });


3

You could over-ride the CSS by using the admin_print_scripts admin_head-media-upload-popup and add css to match your needs. This can be done via the functions.php file or by creating a plugin. Here is the code in a plugin format to begin adding style: <?php /* Plugin Name: Some Name Description: Custom Thickbox Styles */ ...


3

I think what you need is (function(){ var featuredImage = wp.media.featuredImage.frame(); featuredImage.on('select', function(){ var attachment = featuredImage.state().get('selection').first().toJSON(); console.log(attachment); }); })(); The attachment object should have height and width properties.


3

Finally, I found the solution by replacing event handler! Old Scenario (WRONG) $('#TB_window').on('click', '.upload_media a.btn_media_upload', function (e) { //Code } ); New (Working) $('body').on('click', '#TB_window .upload_media a.btn_media_upload', function (e) { // Code });


2

I hate it to answer my own question. But after hours of searching and trying I found a solution that works. I offer this solution, because it can't be interesting for others having the same problem. And for discussion, if there is a better way to get rid of the problem. Perhaps it is not very elegant, but it works ;-) The peak is to change the click-event ...


2

Yep, it's curious that adding the extra parameters doesn't works... I know that Adminimize does that. Looking at its code, that's what it does: wp_deregister_script( 'media-upload' ); wp_enqueue_script( 'media-upload', WP_PLUGIN_URL . '/' . FB_ADMINIMIZE_BASEFOLDER . '/js/tb_window.js', array( 'thickbox' ) ); And this is the tb_window.js ...


2

To get the "Use as featured Image" link you have to pass post_id to the media-upload.php file with the url so the request will be changed to: var post_id = 234 // retrive the post id via php var request = url.media_upload+'?post_id='+post_id+'type=image&amp;TB_iframe=true'; Make sure you add the post_id very first of the url. It didn't worked for me ...


2

I'm guessing front end only, right? function wpse71503_init() { if (!is_admin()) { wp_deregister_style('thickbox'); wp_deregister_script('thickbox'); } } add_action('init', 'wpse71503_init');


2

Interesting question. Investigating it, I've found a [wp-hackers] thread by the same Dion Hulse which gives a bit more of information. First, a testing page with a simple link which will open another admin page in a thickbox. add_action('admin_menu', 'wpse_71437_admin_submenu'); function wpse_71437_admin_submenu() { add_menu_page( 'TB', ...


2

Try something like this... var code = $('div#wp-content-editor-container textarea').text().match(/\[(schema.*)\]/); code = '<' + code[1] + '>'; alert($(code).attr('description'));​​​​


2

Messing up javascript and PHP is not very clever. This answer only confuse. tb_show is javascript add_query_arg is PHP so this solution is only valid in PHP and the proper code is ... ?> tb_show( 'whatever', <?php echo add_query_arg( array( 'action' => 'getTheContent', 'query_var1' => 'value1', 'query_var2' => 'value2', ), ...


1

Localize Wordpress or write and load special localization for your language specialy for thickbox. Thickbox dialogs support localization provided by WP Update - Let's Check 1. You have uncomented string <code>define('WPLANG', 'pl_PL');</code> in your wp-config.php 2. You have localization files in wp-content/languages/


1

For TinyMCE, there is a specific function add_editor_style() for enqueuing a stylesheet in the visual editor. If you call that in functions.php you just put editor-style.css in your theme folder and you're good to go. Otherwise, the function accepts an arg of a custom stylesheet name.


1

This is a short version of what I do in one of my plugins. I copied this behavior from the plugin Advanced Custom Fields (some versions ago, donnow how it proceeds now). 1) When calling the thickbox, add a custom query var (mtt_type in this case): tb_show('{$mtt_title}', 'media-upload.php?type=image&amp;mtt_type=image&amp;TB_iframe=true'); 2) ...


1

tinyMCE isn't implemented as a jQuery plugin. I'm not sure, but this would be more probable: window.parent.tinyMCE.get('editor').getContent()


1

A lot of people think it's a bad practice to deregister/reregister jQuery, despite the performance improvements c/o a CDNed version (and if you're going for a CDN, I see Google's version more often than jQuery's). However, if you're going to do that, you really should only do that on the front-end only so at least the admin can correctly assume that the ...


1

You don’t need to enqueue jQuery if you enqueue ThickBox already. See this answer for details. thickbox.css gets called, jquery.js also. thickbox.js doesn't. Lots of missing details: When do you call the function? Is there markup in the HTML output of your page? A script element for ThickBox? If so, do you get a 404 for the URI? Does the thickbox ...


1

If you're not opposed to using a plugin to achieve this, I would recommend the Multiple Post Thumbnails plugin. It's very simple to use and provides the same functionality as "the_post_thumbnail()" function.


1

I found the way to do it (from a useful comment there http://www.webmaster-source.com/2010/01/08/using-the-wordpress-uploader-in-your-plugin-or-theme/) //lauch on click to appropriate button jQuery('#upload_requestform_button').click(function() { // keep copy of the original send to editor original_send_to_editor = window.send_to_editor; //new ...


1

This line... imgurl = jQuery('img',html).attr('src'); Means that jQuery is getting the "source" (i.e. full path) of the image. As you've guessed, that won't work for a PDF file. What you'll probably have to do is get the id of the attachment instead. Could you possibly update your original answer with the HTML SOURCE of the thickbox? We might be able to ...


1

jQuery(document).ready(function($) { $('.yourlink').click(function() { tbframe_interval = setInterval(function() { $('#TB_iframeContent').contents().find('.savesend input[type="submit"]').val('changed the button text'); }, 2000); tb_show('', 'media-upload.php?type=image&TB_iframe=true'); return false; }); }); ...


1

found it. in the automattic SVN for media.php i found the media_upload_header() function, and the only thing left to do is to echo it in the last function: function media_upload_ell_gmap_form() { echo media_upload_header(); ?> <h2>HTML Form</h2> <?php } that's it.


1

I did something similar for a theme settings page i helped someone with, it looked a little different to what you have, but i'm going to post the code so you can compare. jQuery: Literally just the applicable parts taken from a working script i've used. jQuery(document).ready( function($) { $('img.font').click(function() { form_field = ...


1

it's a longshot but, add_attachment hook, actually fires after the first file finished uploading: add_action('add_attachment','redirect_uploader_flow'); i'm using it to load a custom interface for resizing a Image loading in the current TB window: jQuery("#TB_iframeContent",window.parent.document).attr('src',"<?php echo get_window_url($id) ...


1

This is possibly related to an issue in Wordpress regarding cache that has just been fixed within the last hour: http://core.trac.wordpress.org/changeset/19318 Here's the Trac ticket: http://core.trac.wordpress.org/ticket/19240 Clearing your cache may help in the meantime before beta 4/RC1


1

What if you try adding this to your functions.php function tb(){ wp_enqueue_script('thickbox',null,array('jquery')); wp_enqueue_style('thickbox.css', '/'.WPINC.'/js/thickbox/thickbox.css', null, '1.0'); } add_action('wp_enqueue_scripts','tb'); and keeping your bit of jQuery (not sure what your are needing those php variables for): ...



Only top voted, non community-wiki answers of a minimum length are eligible