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

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 ...


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'], ...


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 */ ...


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

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

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

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', ), ...


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

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.


2

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


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');


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

The issue you are running into is partially an HTML issue. Forms cannot be nested. You are likely putting this inside of another form (as a great bulk of the backend is already forms). WordPress provides good handling for receiving submitted data to extend core functionality. I suggest that you look into this and figure out how to capture the data from ...


1

Answer can be found here: http://stackoverflow.com/questions/13863087/wordpress-custom-widget-image-upload Even though the problem described isn't exactly the same as I had, the code posted in the answer still helped me as that code actually does exactly what I needed. I also think that I didn't originally find this answer as it's on the regular Stack ...


1

My understanding of your question is that you want to use a popup that has contents other than Media Uploader. To achieve this follow these steps: Add this code to include the thickbox script. <?php add_action('init', 'init_theme_method'); function init_theme_method() { add_thickbox(); } ?> Add class='thickbox' to any clickable element that will ...


1

A very basic fix would be to use one() instead of bind(). But why the function is called twice is still open. Ask your browser’s JavaScript inspector.


1

A solution I can think of is creating an almost empty page template that contains the bare minimum header, body (your shortcode) and footer. Create a page with this template and load iFramed. Like: <?php /** * Template Name: Almost Empty Page for Thickbox */ // REPLACE THIS get_header WITH THE CONTENTS OF THE FILE header.php // AND CLEAN UP ...


1

Have a look at this proposed solution. It's an on the fly resizing function. It's actually taken from the ticket prettyboymp posted in the previous answer.


1

Change this: ed.execCommand('mceInsertContent', 0, return_text); To this: ed.execCommand('mceInsertContent', false, return_text); The second argument of the tinyMCE.execCommand() function is a boolean value that states if a UI needs to be presented to the user. Reference: http://www.tinymce.com/wiki.php/API3:method.tinymce.execCommand


1

You need to add a call of wp_footer(); function. Do it before closing body tag in your footer.php file. It should look like this: <?php wp_footer(); ?> </body> </html>


1

In WordPress 3.5, this hook works for me: add_action( 'print_media_templates', 'wpse_75746_print_style_35' ); function wpse_75746_print_style_35() { ?> <style> .media-modal-content, .media-sidebar { background: #FFF2D4 !important; } </style> <?php } In 3.4.2, this is the one: add_action( ...


1

Below, an example of what's needed to use ThickBox. <?php wp_enqueue_style('thickbox'); wp_enqueue_script('thickbox'); ?> <a href="#" id="taxonomy_banner_image" class="taxonomy_banner_image"> Click Here </a> <script type="text/javascript"> jQuery(document).ready(function() { ...


1

There is no solution for this as of WP 3.5. There are a couple of core tickets about introducing the ability defer the generation of specific images sizes on the fly rather than at upload time to prevent the generation of multiple images that will never be used. However, they are far from being included in core at this point. See ...


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

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

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

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) ...



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