We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20093
    • 81 Posts
    Why does the file browser present us with the option of choosing a Media Source for a TV when it is already defined for a TV?

    Ignoring for a moment the outstanding bug which causes the wrong Media Source Label to be shown, choosing a different source actually has no effect and only serves to confuse the user. Would it not be better to simply remove the Media Source menu in this case?
      • 19369
      • 1,098 Posts
      Quote from: MokoJumbie at Feb 18, 2012, 11:59 PM
      ...choosing a different source actually has no effect and only serves to confuse the user. Would it not be better to simply remove the Media Source menu in this case?
      Actually it should have effect, I think you have misconfigured something. On tools > media sources, right click on your media source and choose "update media source", here you need to change both basePath and baseUrl. For example you can use "assets/" as value in both settings. It is working fine on my Revo installation.
        • 20093
        • 81 Posts
        I've defined the baseUrl and basePath. Aside from the wrong source name bug (http://tracker.modx.com/issues/6577), Media Sources seem to be working for TVs.

        What I'm trying to understand is why the user is presented with a choice to select a different Media Source other that what's defined for the TV. It's a false choice, because choosing a different source has no effect on the Media Source attached to that particular TV instance.

        For example:

        For an MODx install in the root of the HTTP server, given a media source of 'Images' with a basePath and baseUrl of 'images/', we define a TV 'ImageTV' of type 'Image' which uses that media source.

        Now, when a user invokes the file browser for that TV, they are presented with a list of files in img/, which is fine. But there are two issues. Firstly, they are incorrectly shown that the Media Source they are looking at is what is defined in default_media_source which is 'Filesystem' by default. Secondly, they are presented with the ability to choose a different Media Source from which to select their file.

        If the user simply ignores the fact that the wrong Media Source name is displayed and selects a file, the TV value is saved as 'image.jpg' and is correctly rendered on the front end as 'img/image.jpg'.

        But if the user selects a different media source, then the path to the file relative to THAT media source's baseUrl is saved in the TV value.

        i.e. It's possible for the user to explicitly select 'Filesystem' which causes the file list to show the files in that source. Now, if they then navigate to img/ to select the desired file, the TV value is saved as 'img/image.jpg' causing the path to be rendered as 'img/img/image.jpg'

        The value newly selected Media Source is never saved to the DB, so it's a false choice. If it were actually saved and then used to render out the correct path then it might be a useful option for the user.

        But then what is the point of defining the Media Source for the TV? All it currently does is control the source initially displayed to the user. And even that is not currently being displayed correctly.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Likewise if one creates an "images" media source linked to assets/images/, and assigns the "Filesystem" media source to a TV the new "images" media source is also listed and available; just as they are both available in the Files tab.
            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
            • 20093
            • 81 Posts
            Yes, i realize this is the case, but I'm not clear about what you're suggesting.

            The default media source for any new TV is the system's default_media_source value at the time of the TV's creation. It's 'Filesystem' by default, which has a baseUrl and basePath of '/'.

            Using your example: If you define 'Filesystem' as the media source for an Image TV, then on an instance of that TV select your 'images' media source and select a file 'image.jpg' (actually located at /assets/images/image.jpg'), the value will be stored as 'image.jpg'. But then, since you have defined 'Filesystem' as the media source, the path will be rendered as 'image.jpg' which is the wrong path.

            I'm sorry my explanation was so long-winded, but it doesn't appear to be a simple problem. Hopefully this reply clarifies thing.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              I was just trying to clarify the problem by pointing out that it works both ways. In other words, a TV should only allow access to the media source that it's assigned; there shouldn't be a list of media sources provided.
                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
                • 20093
                • 81 Posts
                Ah, I see. : ) Thanks for the clarification. I'm glad you agree.

                Not to complicate things, but I think that a better possible solution would be to allow for more than one media source to be defined for a TV, and to present only those defined sources as options in a list. If only one source is provided, perhaps the list shouldn't be presented at all.
                  • 19369
                  • 1,098 Posts
                  @MokoJumbie, I agree, that's not the right behaviour of Media Sources, they've just implemented it so I guess some features will be added in future releases. Probably it is a good idea if you put a feature request for this on MODX project tracker.
                    • 20093
                    • 81 Posts
                    FYI, I finally got around to creating an issue for this in the tracker: http://tracker.modx.com/issues/7491