Allow author to upload image via Media button without plugin

in the basic configuration the user role contributor and subscriber do not have the capability upload_files. The user role author has this capability. The capability upload_files gives the user the panels “Media” and “Media > Add New”. If you want another role to grant this capability, you can use the function add_cap(). Since such changes … Read more

Renaming “Expand Details” within “Add Media”

It’s possible to change the output of the label with jQuery but I’m not sure the best hook to do this besides admin_footer. // Collapse var $open = jQuery(‘.acf-expand-details > .is-open’), $open_icon = $open.find(‘span’); $open.html(‘MIN Details –>’); $open.prepend($open_icon); // Expand var $close = jQuery(‘.acf-expand-details > .is-closed’), $close_icon = $close.find(‘span’); $close.html(‘<– MAX Details’); $close.prepend($close_icon); add_action( ‘admin_enqueue_scripts’, … Read more

WP media attachment location vs permalink

I think a possible solution could be following codesnippet from Mark Kaplun. To solve issues with this you could remove the http part and WordPress will/should use https instead. Because the rest of your website is working correctly I assume that further settings are correct and will do their job as wished. add_filter(‘the_content’,’wpse_217012′,1000,1); // remove … Read more

WordPress Media Delete Logs

From a quick look there is a dedicated delete_attachment action in wp_delete_attachment() function, it gets passed an ID of attachment being deleted. However I am not completely confident that this covers all cases. There is a fair amount of duplication in WP’s post–related APIs and similar tasks might be performed by different functions in different … Read more

Adding fields to attachment – only shows when inserting new attachments

Okay I think I have it, you need to add a matching filter to attachment_fields_to_save to save the new field (say as post meta to the attachment.) add_filter( ‘attachment_fields_to_save’, ‘save_some_custom_field’, 10, 2 ); function save_some_custom_field($post, $attachment) { $attachid = $post[‘ID’]; // yes this is actually an array here update_post_meta($attachid,’someCustom’,$attachment[‘someCustom’]); } Then you would add to … Read more