alicolville / Weight-Tracker

Wordpress plugin: https://wordpress.org/plugins/weight-loss-tracker/
5 stars 4 forks source link

Image upload folder #570

Open shakethatweight-simon opened 7 months ago

shakethatweight-simon commented 7 months ago

Is it possible to change the location of the image/progress photo upload so it's not mixed in with the main media folder? We have other members of the team who may edit and update the site and there is no reason for them to see these images.

shakethatweight-simon commented 7 months ago

@alicolville Have you got any ideas how this could be achieved?

alicolville commented 7 months ago

Ah not really, I would probably need to build an separate media handler that doesn't use the standard WP library.

I can't find anything around media library permissions (e.g. hide WT images from certain user roles). :(

shakethatweight-simon commented 7 months ago

We use this at the moment to hide the images from the media library in grid view, but doesn't work in list view.

add_filter('ajax_query_attachments_args', function($args) {
    if ( $args['post_type'] == 'attachment' ) {
        $args['meta_query']['relation'] = 'OR';
        $args['meta_query'][] = [
            'key' => 'ws-ls-hide-image',
            'compare' => 'NOT EXISTS',
        ];
        $args['meta_query'][] = [
            'key' => 'ws-ls-hide-image',
            'value' => 0,
        ];
    }
    return $args;
}, 10, 1);

I did find some Wordpress hooks that might be useful, but it would mean some updates to the plugin. If I get some spare time I'll take another look at it.

alicolville commented 7 months ago

That could be a potential route, but I probably wouldn't do it on ws-ls-hide-image for the general plugin as some want the images in media library. I guess another suitable key could be a solution...

Happy to look into this at some point, so yes, if you find any more good documentation, dump it in here for me :)