Tag Info

Hot answers tagged

8

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


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

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

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

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


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

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

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

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

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

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

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

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

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

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


1

what i ended up doing was launching the thickbox uploaded manually via a jquery click event. then with setInterval i was able to hide the pieces i wanted. jQuery(document).ready(function($) { $('.specialclass').click(function() { //get post id from somewhere (for me this was the row column string = ...


1

The fileurl should look like this: fileurl = $('a', html).attr('href'); It's a pretty simple fix. I would do some validation on this: if(/\.mp3\b/.test(fileurl)){ //Do something awesome }else{ alert('The file you selected is not an MP3.'); } Cheers!


1

It's more a hack than a solution. You could use a regex to extract the attachment ID from the wp-image- class. Add the following snippet to your window.send_to_editor function. $classes = jQuery('img', html).attr('class'); $id = $classes.replace(/(.*?)wp-image-/, '');


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('init','tb'); and keeping your bit of jQuery (not sure what your are needing those php variables for): ...


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

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

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

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

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

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



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