NewsPublisher - using a unique media source for registered users

Hey all,

Is possible to have NewsPublisher to point to an unique media source when they are trying to insert/edit an image via TinyMCE? Currently right now, TinyMCE points to assets directory but I would like to do the following…well my thoughts:

  • When the user registers via the “Register” Snippet, I would create a media source for that user (probably via the post hook). For example:
    Media Source name: MS_{resource_groupname}_{userid}
    baseUrl and basePath = “assets/content/{resource_groupname}/{userid}”
  • When the user creates a post with NewsPublisher, I would use the userid to find the user’s media source, and will points to it. I trying to prevent the user from seeing the entire assets directory

Does anyone has any ideas how this can be done? If this is not a viable solution, what would be a good alternative?

Also, is it a good idea to create multiple media sources? The website could possibly grow to over 100,000+ users.

The extra MIGX has a snippet migxResourceMediaPath. The idea is, that instead of a fixed value for the properties basePath and baseUrl of the media source, you call this snippet and that returns a dynamic value (based on the resource-id, user-id etc.).

Maybe this (or something similar) works as well for Newspublisher. I never tried it. You’d have to test that.


An example for MIGX:
https://docs.modx.com/current/en/extras/migx/migx.tutorials/use-resource-specific-mediasource-and-multifile-uploader#create-the-dynamic-resource-specific-media-source

In your case you probably want to use {userid} in the &pathTpl.

These are from the NewsPublisher docs:

The &browserBasePath and &browserBaseURL properties of the npElfinderConnector snippet are set to the assets directory. You may want to change them, but be sure they match. Users will not be able to browse above them.

The &browserStartPath and &browserStartURL properties allow the browser to open in a lower directory. The two must match. Users will be able to browse above them, but only up to the &browserBasePath and &browserBaseURL directories.

I’m pretty sure you could override those values with a User Setting or a UserGroup Setting, as long as those settings are not in your snippet tag.

If you replace tinyMCE with Redactor, you can use placeholders such as username in the upload path, so each user ends up with their own folder of uploads.

What I don’t know is 1. Can Redactor be used with NewsPublisher and 2. Can a user be prevented from navigating above their own folder…

Ok, thanks for the suggestions. I’m going to test them shortly and let you know my findings