How to handle multiple instance of “send_to_editor” js function

only overwrite the send_to_editor function when your link or button is click but store the old function to restore it so try this on a click event: //store old send to editor function window.restore_send_to_editor = window.send_to_editor; //overwrite send to editor function window.send_to_editor = function(html) { var imgurl = jQuery(‘img’,html).attr(‘src’); current_item.siblings(‘.upload_image’).val(imgurl); current_item.parent().prepend(‘<div><img width=”300″ src=”‘+imgurl+'” alt=”banner image” … Read more

How to call WP3.5 Media Library manager?

From the article How to use WordPress 3.5 Media Uploader in Theme Options (by codestag.com), as seen in Using the WordPress 3.5 Media Uploader within plugins (by mikejolley.com). Mike Jolley’s article has quite some nice tricks. Important note: if the page where the uploader is going to be used doesn’t already have all media JS … Read more

How to upload image with simple form?

There are several parts. You need to add an enctype to the profile form. function edit_form_type_wpse_98375() { echo ‘ enctype=”multipart/form-data”‘; } add_action(‘user_edit_form_tag’,’edit_form_type_wpse_98375′); Then add a field to the form. function user_fields_wpse_98375($profileuser) { $_profile_photo = get_user_meta($profileuser->data->ID,’_profile_photo’,true); echo ‘<h3>’.__(‘Additional User Data’,THEME_TEXTDOMAIN).'</h3>’; echo ‘<tr class=”show-admin-bar”>’; echo ‘<th scope=”row”>’.__(‘Profile Photo’, THEME_TEXTDOMAIN).'</th>’; echo ‘<td’.$tspan.’>’; echo ‘<fieldset>’; echo ‘<legend class=”screen-reader-text”><span>’.__(‘Profile Photo’, … Read more

Missing a temporary folder despite settings in wp-config.php

try to use get_temp_dir() to see if wordpress is using your WP_TEMP_DIR constant. i’ve tried this code in wp-config.php and it works define(‘WP_TEMP_DIR’, dirname(__FILE__) . ‘/wp-content/temp/’); but you have to put it before the /* That’s all, stop editing! Happy blogging. */ in your wp-config.php file.

Is it possible to trigger some JavaScript when Media Popup is opened?

You can use several event handlers. frame.on(‘open’,function() { // Do something }); frame.on(‘close’,function() { // Do something }); frame.on(‘select’,function() { // Do something }); Where frame is a reference to wp.media() frame = wp.media(); frame.on(‘select’,function() { // Do something }); Full example Script en-queued with jQuery and media editor as dependencies. function media_script_enqueue() { wp_enqueue_script( … Read more

Large Uploads in WordPress

70-80MB is really not that large. Easily handled by the Flash uploader if your server is properly configured. Hell, I have a 2 gigabyte upload limit on my site. 🙂 When they’re writing the new “post”, they just click the add media button above the toolbar and upload it. It gets saved as an attachment … Read more

How do I link directly to uploaded files?

If I upload the file to WordPress’ upload directory through FTP, I don’t see the file show up in my media (in WP-admin) Try to avoid directly uploading via FTP. WordPress doesn’t scan your uploads folder for new images. Instead, use the built-in media uploader within WordPress to upload images. WordPress will automatically place them … Read more

How to add image uploader to a custom widget?

Firstly, it is not recommended to use WP_PLUGIN_URL constant, instead use plugins_url() function. Second thing, it will not work when you put your files in the theme. You must put the necessary folder and file in the plugin if have to use this constant or function. Make sure, you have put correct path and you … Read more