We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10696
    • 35 Posts
    Description of Problem:
    Hello everybody! Here is what I need:

    I need to create a custom MediaSource for non-administrative backend content editors. The idea is simple and clear -- give to content editors access only to one folder for image storage purposes, e.g.
    assets/common/


    OK, I've created a user, user group, resource group, and custom policy based on 'Content-Editor' policy with file_* and directory_* permissions. Also there was checked source_view permission, I'm not sure was it by default or not.
    Then I've created MediaSource with following configuration:
    BasePath = assets/common/
    BasePathRelative = Yes
    BaseURL = (blank)
    BaseURLRelative = Yes


    Then I've mixed it all together, set user as MediaSource Admin and faced the first problem: to get access to files in my MediaSource I need to set BaseURL to 'manager/', because other way I can't even fetch filelist in my MediaSource.

    OK. 'No problems!' I've thought. But I was wrong.

    Second problem is that my editor can switch between media sources and choose Filesystem even if there is only one media source allowed (my custom media source) and gain full access to files. I've tried to uncheck 'source_view' in my editor's policy. This is not solved my problem, because in this case editor can't choose mediasource and Filesystem is set by default. Tested several times, every time the same behavior. At this point I left 'source_view' checked.

    Then I faced the last problem which led me to the Forums after few hours of combining different setting together.
    First I've noticed that when I try to insert image into resource final image url is incorrect.
    Example:
    BasePath = assets/common/
    BasePathRelative = Yes
    BaseURL = manager/
    BaseURLRelative = Yes

    Final URL is manager/assets/common/ instead of assets/common/

    Then I've tried to change BasePath to full path and switch BasePathRelative = No, create folder in 'manager' folder and share it, change base URL to <sitename>/manger and switch BaseURL to No, and mixing that parameters all together, each time logging out and in my editor.

    After a few hours of attempts I'm totally confused. How can I make this work? It there a clear guide to configure custom media source?

    Please help somebody!

    P.S. Forgive me if my explanations are unclean and forgive me my mistakes. I'm from Russia and sometimes it's realy hard to explain exactly what I mean in English.


    • MODX Version: 2.2.5-pl traditional
    • PHP Version: 5.3.13

    This question has been answered by Geraldus. See the first response.

    [ed. note: Geraldus last edited this post 13 years, 10 months ago.]
    • discuss.answer
      • 10696
      • 35 Posts
      Oh, I've resolved almost all issues referring to MODx Dashboard:
      First I've changed my custom media source configuration to
      BasePath = assets/common/
      BasePathRelative = Yes
      BaseURL = assets/common/
      BaseURLRelative = Yes

      (reference)

      Second, I've changed default media source in sytem configuration (reference)

      But now I have issue with image thumbnails while browsing folders via FileManager, e.g.
      When selected file relative path '/assets/common/folder/img.jpg'
      thumb src is 'connectors/system/phpthumb.php?src=folder/img.jpg'. [ed. note: Geraldus last edited this post 13 years, 10 months ago.]
        • 10696
        • 35 Posts
        Looks like issue with FileManager is bug.

        I think FileManager should check path before creating thumbnails. If path is relative then FileManager should prepend base path so phpthumb could find image and create proper thumbnail.

        The logic is:

        FileManager opened
        Get default MediaSource configuration
        Store MediaSource base path in some var
        Is MediaSource base path is releative -> Get MODx base path and prepend to stored value
        When creating thumbnail for image use stored value
        When MediaSource changed check its config again

        Thus, the idea is to add described logic to FileManager script.

        Does anybody know where can I find it?

        Or, maybe there is another way do that, for example plugin based solution if there are proper MODx event to handle FileManager behavior?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I've always added the trailing slash to my path and URL; I'm not really sure if it's necessary.
          BasePath = assets/common/
          BasePathRelative = Yes
          BaseURL = assets/common/
          BaseURLRelative = Yes
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 10696
            • 35 Posts
            Quote from: sottwell at Nov 28, 2012, 08:26 AM
            I've always added the trailing slash to my path and URL; I'm not really sure if it's necessary.
            BasePath = assets/common/
            BasePathRelative = Yes
            BaseURL = assets/common/
            BaseURLRelative = Yes

            Oh, sorry! This is typo! The tailing slash is required (this described only here). Originally I HAVE tailing slash in config. I'll edit my messages.
              • 10696
              • 35 Posts
              I've uploaded several images. Now I see that some of thumbnails renders properly. But others do not.
              Look at my sreenshot in attachments.
              So, this is not bug at all. The quetion is why some of thumbnails do not renders correctly? [ed. note: Geraldus last edited this post 13 years, 10 months ago.]