frugan-dev / acf-uppy

ACF Uppy Field is a WordPress plugin that adds a new "Uppy" custom field to the list of fields of the Advanced Custom Fields plugin
GNU General Public License v3.0
5 stars 1 forks source link

Add Video's to media library and to WordPress folders ie year/month #4

Closed vayurobins closed 9 months ago

vayurobins commented 3 years ago

Hi, this is a nice script, thanks for sharing. Would it possible to add Video's to the media library and store the in the WordPress folders ie. year/month

frugan-dev commented 3 years ago

Hi @vayurobins,

this plugin does not create any default limitations on the type of files that can be uploaded. There is a specific field in BO to set a limitation on mime-types, otherwise you can leave it blank, if you want to allow the upload of any files.

Default destination of the uploaded files is {ABSPATH}wp-content/uploads/acf-uppy; but you can use these two hooks to vary it as you like (eg. {ABSPATH}wp-content/uploads/year/month):

apply_filters( 'acf_uppy/dest_path', $destPath );
apply_filters( 'acf_uppy/dest_path/type={$postType}', $destPath, $postId, $field );

I hope I was helpful, otherwise please feel free to reply! And if you like this project, consider leaving a star to make it more popular, thanks!

frugan-dev commented 3 years ago

Sorry I re-read your post better and maybe I understood what you meant .. The data is handled by Advanced Custom Fields, so you might try using eg. this action https://www.advancedcustomfields.com/resources/acf-save_post/ to duplicate the data on the WP media library.

vayurobins commented 3 years ago

Thanks for your feedback. Should it not be so, that all files are added to the media library by default? I would think that anything that has to do with media files in WordPress, should always be added to the media library, which is standard behavior. As for as I know, is that Advanced Custom Fields always adds media files to the media library. What is the reason for not doing this?

frugan-dev commented 3 years ago

I understand your reasons.. the reason is that this plugin allows you to save files above the public folder, that is, not exposed publicly, therefore not reachable via direct url. Files, even large ones, can be downloaded via symlinks created on the fly, and, if necessary, after a check on user authentication, eg. see filters:

apply_filters( 'acf_uppy/download_allow', $allow, $destFile, $postId );
apply_filters( 'acf_uppy/download_allow/type={$postType}', $allow, $destFile, $postId );

If I had used the WP media library, as far as I know, this would not have been possible, ie knowing the url the file would have been publicly downloadable.