Media upload finished hook

I'm developing a plugin which uses wordpress's thickbox media library to handle media upload and selection. All is well but for the fact that I would like to automatically 'redirect' to the 'media library'-tab after I uploaded/ wordpress finished crunching the file. So basically i'm looking for a hook that's fired after the crunching of an uploaded file is finished. I can't imagine this would be such an extreme thing but I can't seem to find the right hook for …
Category: Web

Custom media upload content for inserting custom post shortcode

I’m working on a plugin that creates custom post type “portfolio” along with shortcode to insert in any page or post. The shortcode is: [portfolio option1=“1” option2=“0” option3=“1” ] And it works just fine, it shows all custom posts via custom WP_query. But I want to go further. Create a custom button next to upload media for generating a portfolio shortcode output, where user can select which post to include and define all options. So the output would be: [portfolio …
Category: Web

ThickBox width can't be changed in admin

I'm trying to make pop up in admin area (in post edit screen) and i can't make my thickbox wider then 670px (width: 670px). Here's my thickbox code that shows thickbox: tb_show( ed.getLang('m7.popup_title'), '#TB_inline?width=800&height=600&inlineId=mygallery-form' ); (it works after clicking the tinyMCE button) and i get div with id="TB_window" <div id="TB_window" style="width: 670px; height: 216px; margin-left: -335px; top: 48px; margin-top: 0px; visibility: visible;"> (code is from google browser) So if i manualy change width and then resize browser it gives 670px …
Category: Web

WordPress Thickbox Navigation Issue in Gallery

I am adding an image gallery via wp media uploader. In the frontend, I am trying to show these images in Thickbox pop-up. However, it shows the images in pop-up but when I navigate [next and prev images] it suddenly works and an error is seen in the console. This is the error: http://example.com/wp-content/uploads/2019/03/IMG_0139.jpg&width=753&height=470?random=1555568706302 404 (Not Found). If I paste this url, 404 page is seen. All in all, the navigation buttons are not working properly. If I add 2 …
Category: Web

Open a Thickbox with content trough AJAX

I added a custom button to the TinyMCE editor, and I want to open WP's Thickbox when I click on it. How can I make it so that the tb_show() function loads the content I want with ajax? // the ajax add_action('wp_ajax_getTheContent', 'getTheContent'); function getTheContent(){ echo 'weqwtegeqgr'; // <- this should be displayed in the TB die(); } Here's some of the editor plugin code I'm using: init : function(ed, url) { ed.addButton('do_stuff', { title : 'Do Stuff', image : …
Category: Web

WP Dashboard video modal on load

I was able to create a dashboard modal using add_thickbox();, triggered by a link: <a href="#TB_inline?width=600&height=550&inlineId=my-content-id" class="thickbox">View my inline content!</a> <div id="my-content-id" style="display:none;"> <p> This is my hidden content! It will appear in ThickBox when the link is clicked. </p> But actually I want it to work like this: 1) When the logged in user is redirected to the dashboard for the first time (and only the first time), the modal should appear automatically, with a button to remove the …
Category: Web

Form within thickbox

When I try and insert a form into a thickbox for use in the admin area, it seems to be removed completely. What do I need to change? <?php // Enqueue thickbox js and css add_thickbox(); ?> <div style="text-align:center;padding:20px 0;"> <input alt="#TB_inline?width=500&height=600&inlineId=examplePopup1" title="Insert/edit link" class="thickbox" type="button" value="Tickbox 1" /> </div> <div id="examplePopup1" style="display: none"> <div name="buffer"> <form name="test" action="www.test.php" method="post"> <input type="text" class="item-permalink" value="test"> <input type="submit" value="Add Link" class="button button-primary" id="link_form-submit" name="link_form-submit"> </form> </div> </div> In the browser I simply …
Category: Web

How to customize WordPress Thickbox?

I've been able to do a certain amount of styling via CSS, but I'd like to add divs and more to the navigation elements - in other ords, I need to be able to somehow edit the actual js file, but obviously don't want to do so since it would just be overwritten on future updates. Surely there are functions/hooks that would make this possible? Or, would it work similar to how other theme files operate in that simply creating …
Category: Web

open modal window

I am working on a site where HR employees are managing applicants for jobs. I'm currently trying to add a modal window on a custom admin dashboard that will let a user quickly change an applicant's status. The dashboard lists applicants by job title, with a few of the more important fields displayed (resume download, the date they applied, etc.): Clicking on the "change" button below the applicant's status would open a modal window where the manager could select and …
Category: Web

Run script after clicking Set Featured Image in Media

I would like to run some script to get the featured image's width and height after the user clicked 'Use Featured Image' button and use the data retrieved within the Post Edit screen. Is there such hook available for use in JavaScript? Otherwise, do you have other suggestions to achieve this? Thanks for helping! Edit : If there isn't any hook, I tried using the code below but clicking 'Set Featured Image' wouldn't trigger the event, presumably because it's a …
Category: Web

Wordpress Admin Thickbox: Remove Margins/Padding

I've added a Thickbox to an admin page by adding the the following action hook to add the library code add_action( 'in_admin_footer', function(){ add_thickbox(); }); And then triggering an inline thick box manually via some javascript code tb_show(null,'#TB_inline?height=300&width=300&inlineId=id_of_div_with_my_thickbox',false); When I do this, the thickbox has some margins/padding on the left and right (see in screenshot below how everything is centered) I'd like to Remove these styles for everything is flush against the Thickbox (as a style reset) But only for …
Category: Web

Howto use WP built in Thickbox for images?

I've been searching for a better way to utilize the built in Thickbox function for images. I've been using my method for a few months, but I don't think it's the best way to do it. Here is the code I've been using (I don't remember where I found the code or I'd link to the article): <?php if (!is_admin()){ /* add a word found in your domain name */ $mydomain = ".com"; /* The css selector .entry-content a img …
Category: Web

Custom Thickbox Broken on Dashboard Page?

I'm working on an extension that, as part of its functionality, adds Thickboxes to many pages in the Wordpress admin. On most pages this works fine -- I use an in_admin_footer action hook to call add_thickbox, and include the HTML/Javascript (via an include statement) that includes the Thickbox. add_action( 'in_admin_footer', function(){ add_thickbox(); include(__DIR__ . '/includes/thickbox-div.php'); }); And my Thickbox href string looks like #TB_inline?height=480&width=480&inlineId=my_div_id This works great -- most of the time. However, on a few admin pages (dashboard, plugins), …
Category: Web

How to Add Custom CSS to the Media Thickbox?

I've added a couple of custom fields to the Edit Media screen, but when these are displayed in the WP Media Thickbox (when adding images from the Edit Post screen, for example), the styling is gone. Is there a hook to add my custom css to the Thickbox iframe when it loads?
Category: Web

Access tinymce from thickbox

Basically, I have a custom tinymce button which opens a thickbox window in iframe mode. Is there a way to access the tinymce from the iframe? Wordpress media uploader seems to do it somehow. Stuff like $('#content', window.parent.document).tinymce().getContent() does not work. PS. If that's impossible, I'll have to do use the tinymce default popup window, but Good God it's ugly.
Category: Web

Is there a hook to put stylesheet and/or JS inside iframes (thickbox or tinyMCE) in admin area

I'm working on my admin area theme and I wanted to make some modifications on the way the thickbox and tinyMCE looks. I could make most of the changes through adding custom stylesheets and JS to my admin area using wp_enqueue_script() and wp_enqueue_style(), but I have had a hard time making some others changes. This is because the iframes containing the elements are either not reachable by my own styles or have in their head some other stylesheet and JS …
Category: Web

How to hook into wordpress admin upload iframe?

I have written a plugin which lets the user upload file attachments for using WordPress as a download site. So I have added a meta box which shows the user the files he has uploaded for every post. Everything is working fine until I wanted to make it so that if a user uploads file using the built-in upload manager and then closes the ThickBox a function of mine is invoked to update that meta box for new files. In …
Category: Web

Error with Custom Admin Screen in iframe Thickbox

I have a plugin that adds a new admin screen in an iframe. I created a PHP file in my plugin, and I put a link with a class of Thickbox to that. Everything works just fine, but it produces a PHP error when WP_DEBUG is set to true. Looking at the WordPress source code, there's no way around the error if I put a PHP from outside /wp-admin/ directly in an iframe. Notice: Undefined offset: 1 in .../wp-includes/vars.php on …
Category: Web

Custom height/width for thickbox in WP Backend

I use thickbox in the WP backend for preview or other content. On own pages in the backend works my script very fine and a can use custom width and height for the thickbox. below my code: <script type="text/javascript"> <!-- var viewportwidth; var viewportheight; if (typeof window.innerWidth != 'undefined') { viewportwidth = window.innerWidth-80, viewportheight = window.innerHeight-100 } else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) { viewportwidth = document.documentElement.clientWidth, viewportheight = document.documentElement.clientHeight } …
Category: Web

How to open the add media dialogue it in a certain state / tab?

I created a customized wp_view similar to embed (see wp-includes/js/mce-view.js, l. 868). I also have my own tab in the "add media" dialog. Naturally I want the edit button of my wp_view opening the add media dialog with the right tab. Currently I use this: edit: function(text, update) { tb_show('Some headline', 'media-upload.php?tab=mytab&someparams='+somevalues+'&TB_iframe=true'); } I works like a charm, but the edit and delete buttons keep staying in foreground, even before the thickbox. in the codex is written: As of WordPress …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.