• I have a project where the client has the desire is to retain overall editorial control of the look of a series of WordPress multi-sites whilst allowing the site admin the freedom to customise the frontend. The intent is to create a library of quality images in the correct dimensions with suitable subject matters so that the user does not need to find their own images. The hope is this will give the user the feel that they are creating their own pages whilst maintaining the quality and aesthetic of the sites.

    • I need to restrict users in the WP admin from uploading their own images.
    • The library images could be grouped into directories by dimension.
    • When the user goes to edit an area of the front page the media frame will present just the images suitable for that area of the page.
    • The user needs to be prevented from uploading their own images to these areas.

    Any thoughts on the best way to achieve this functionality would be appreciated
    Thanks
    Mark

    • This topic was modified 5 years, 5 months ago by nxtpixel.
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    If the user role (even administrator) whose uploads are to be restricted lacks the “upload_files” capability, then they cannot upload. They can still insert images from the media library. The code to remove capability isn’t too complex, or there are plugins that will help with this. The change persists, so don’t try to do so with code that runs on every request.

    The usual upload process includes filters so you can change where images are uploaded to. As long as the related attachment post has the image’s correct path, I believe they’ll show up in the media library where ever they reside. However, as for limiting what appears by where they are in the edit area, that gets more involved. You can alter the media library query to only get certain attachments easily enough. I’m unsure how the filter callback to do so would know where a user is in the edit area. You’d have to start with JavaScript or jQuery to know where they are in the editor. Somehow that information would need to be passed to the server so when the media library is requested the attachments queried can be restricted accordingly.

Viewing 1 replies (of 1 total)

The topic ‘Restricting image selection in WordPress admin’ is closed to new replies.