• Resolved brtech

    (@brtech)


    Hello

    Thanks for maintaining this plugin. I love it :).
    I need to limit the file size for images, so huge images are rejected after upload. Whats the way so it works with your plugin? It looks like using wp_handle_upload_prefilter is not useful cause this plugin works around it.

    Please advise.
    Thanks, kr Jay

Viewing 1 replies (of 1 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for the positive feedback and for your question. I can give you a few suggestions for your application.

    MLA does hook the wp_handle_upload_prefilter but does nothing unless the MLA-specific mla_upload_prefilter is also defined. If you haven’t defined the MLA filter you can use the WordPress filter however you like. You can also use the WordPress wp_handle_upload filter in the same way. The MLA filter is used in two “Mapping Hooks Example” plugins.

    I also found another WordPress filter in the /wp-admin/includes/file.php file you can consider:

     	/**
    	 * Filters whether to short-circuit moving the uploaded file after passing all checks.
    	 *
    	 * If a non-null value is passed to the filter, moving the file and any related error
    	 * reporting will be completely skipped.
    	 *
    	 * @since 4.9.0
    	 *
    	 * @param string $move_new_file If null (default) move the file after the upload.
    	 * @param string $file          An array of data for a single file.
    	 * @param string $new_file      Filename of the newly-uploaded file.
    	 * @param string $type          File type.
    	 */
    	$move_new_file = apply_filters( 'pre_move_uploaded_file', null, $file, $new_file, $type );
    

    I haven’t done any testing of my own, but any of the WordPress filters should work for your application without any interference from MLA. I am marking this topic resolved, but please update it if you have any problems or further questions regarding the above suggestions. Thanks for your interest in the plugin.

Viewing 1 replies (of 1 total)

The topic ‘limit file size’ is closed to new replies.