Use Media Uploader on Multiple Images on same page

So I set a new variable of target_input that grabs the previous input field ID, this input is where I want the URL of the selected media stored, this is done in the click function of the button that selects the media. That variable is used to attach the URL. jQuery(document).ready(function($){ var custom_uploader; var target_input; … Read more

Unable to Upload Files

I figured out the issue. Under Settings > Media there is a text field saying where to upload the files to, and it was the wrong directory. I just changed it to the right one and it worked.

Getting all URLs of uploaded images using media uploader

Got it working with a code from this question https://stackoverflow.com/questions/14847668/get-url-of-freshly-uploaded-image-from-wp3-5-media-uploader Maybe somebody will find it useful. This code logs URL of every freshly uplaoded image to console. jQuery(document).ready(function($){ $(‘#upload-btn’).click(function(e) { e.preventDefault(); var image = wp.media({ title: ‘Nahranie obsahu’, // mutiple: true if you want to upload multiple files at once multiple: true }).open() .on(‘select’, function(e){ … Read more

Uploading images on front end doesn’t generate thumbnail sizes

wp_generate_attachment_metadata generates metadata for an image attachment. It also creates a thumbnail and other intermediate sizes of the image attachment based on the sizes defined on the Settings_Media_Screen. wp_generate_attachment_metadata() is located in wp-admin/includes/image.php. /* just require image.php before wp_generate_attachment_metadata */ require_once(ABSPATH . ‘wp-admin/includes/image.php’); $attach_data = wp_generate_attachment_metadata( $attach_id, $file ); hope that helps!

Generating different dimension images while uploading image file from custom plugin page

Resized different dimension image sets are generated by using wp_generate_attachment_metadata and wp_update_attachment_metadata method. $absFilename = $wp_upload_dir[‘path’].”https://wordpress.stackexchange.com/”.$filename; $attach_data = wp_generate_attachment_metadata( $attach_id, $absFilename); wp_update_attachment_metadata( $attach_id, $attach_data ); This will update the image details in the wp_postmeta table. Thanks @DaveRomsey

Allow Author on Site A capability to upload files on Site B in Multi Site

Look into switch_to_blog() and its required follow up, restore_current_blog() I left comments in code for basic idea to adapt into your function. It may need tweaking, and can probably be improved. //Site B add_action( ‘init’, ‘site_a_author_upload_site_b’ ); function site_a_author_upload_site_b() { if ( is_user_logged_in() ) { //get a WP_User object of current user $current_user = wp_get_current_user(); … Read more