wp_enqueue_media(); in multiple widgets

Your actual issue is that you are using $(‘.custom_media_url’).val(attachment.url); without selecting the exact field you need. This selects every .custom_media_url field on the page, e.g. each field within each widget. Since you are using jQuery, you can replace this line: $(‘.custom_media_url’).val(attachment.url); with $( e.target ).siblings( ‘.custom_media_url’ ).val( attachment.url ) However, using wp.media.editor is not the … Read more

Getting the Select and Crop Functionality Using Custom Fields

I have a partial solution where I can add a image crop uploader to the theme customization page. I have yet to figure out how to attach it to acf. function add_my_media_controls($wp_customize) { $wp_customize->add_section( ‘theme_banner_image’, array( ‘title’ => __( ‘Banner Image’, ‘theme_banner_image’ ), ‘priority’ => 35, ) ); $wp_customize->add_setting(‘banner_image’, array( ‘type’ => ‘theme_mod’, ‘capability’ => … Read more

How to share media between independent blogs?

I’m afraid you’ll also need to create the database records – that’s how WP looks for media files, starting in the db. Those records then tell WP the local path to the media file. But that means that if your web server has access to both sub domain folders on disk, you don’t need to … Read more

45mb File Exceeds the Maximum Execution Time

No it’s not. Unless you have a connection that is being interrupted, or is very slow. Here is what you can do: Option 1 Increase the PHP max execution time. Ask your host provider to increase it, or if you have access to it, update this line in your php.ini file: max_execution_time = 999 Option … Read more

WP default file upload hook not working if used in a plugin

maybe validate_user_storage_space is firing too early or its too late. try wrapping this function inside another function then hook second function with one of below action hook init or after_setup_theme or plugins_loaded like below. add_action( ‘init’, ‘validate_user_init’ ); //after_setup_theme plugins_loaded function validate_user_init(){ add_filter(‘wp_handle_upload_prefilter’, ‘validate_user_storage_space’, 1); add_filter(‘wp_handle_sideload_prefilter’, ‘validate_user_storage_space’, 1); } function validate_user_storage_space( $file ) { //your … Read more