On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Based on what I’ve found in the forums or reading the docs it seems like you should be able to set a different media source for each context:

    http://rtfm.modx.com/revolution/2.x/administering-your-site/media-sources/securing-a-media-source/creating-a-media-source-for-clients-tutorial#CreatingaMediaSourceforClientsTutorial-DifferentContexts

    This works perfectly with template variables but in the main rich text editor window if you add an image (or link) the resource browser loads the directory that is associated with the “default_media_source” in the main “System Settings” (it ignores the context setting). I’ve tested this with both CKEditor and TinyMCE and neither work.

    The URL that is called for the resource browser popup looks like this:

    /manager/index.php?a=3&source=3&CKEditor=ext-comp-1091&CKEditorFuncNum=3&langCode=en

    So the “source” media id is being recognized correctly (source=3) but this isn’t being passed to the directory listing script:

    /connectors/browser/directory.php?action=getList&id=/ (POST value has source=1)

    After some digging and experimenting with the source code I think that both editors are using an old URL parameter. If you call the resource browser with the following the context media source loads correctly:

    /manager/index.php?a=3&ctx=context_name&CKEditor=ext-comp-1091&CKEditorFuncNum=3&langCode=en

    So as a fix I made the following changes:

    CKEditor

    /manager/assets/components/ckeditor/modx.htmleditor.js

    Line 207 change to

    filebrowserBrowseUrl: MODx.config['manager_url'] + 'index.php?a=' + MODx.action['browser'] + '&source=' + MODx.config['default_media_source'] + '&ctx=' + MODx.config['wctx'], // TODO !!!
    



    MODX 2.2.10 core files

    /core/model/modx/processors/system/config.js.php

    Line 53 change to:

    'resource_classes' => $resourceClasses,
    'wctx' => $workingContext->get('key'),
    );
    


    The only issue with these changes is that they will break once MODX is updated (I'm guessing the "&source=" URL parameter used to work but was recently deprecated?).
    • Thanks for posting this. It might explain an issue I recently posted about in the 'bugs' forum.

      I created a new media source, and thereafter all thumbnails, both in the manager (i.e. for media type TVs) and resource browser were broken.

      In addition, when I used the resource browser in the new context, which was configured to look directly into /assets/images/, I didn't see thumbnails at all.

      I did not [think to] check the source, but do you think based on what you found that this was the issue? If so I'll try editing the code as described in your post.