We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37514
    • 178 Posts
    I've just tried using media sources with Image TVs, and found that MODX now expects the image TV to output the whole <img> tag.

    All TV content created with a specific image TV is expected to have the same alt, class etc, as far as I can see. ( Manual page)

    This seems quite unlike MODX - I need to apply specific alt and classes to the image, which I can do by nesting TVs into the initial TV, but this then seems to break when the image TV is summoned in a Snippet like getResources, and TVs inside are rendered via [[+placeholders]].

    I seem to be faced either using the TV without media sources, or losing the ability to output alt tags or classes when I use image TVs through snippets. Am I missing something?
      • 3749
      • 24,544 Posts
      If you set the type of the TV to image on the Input Options tab, then look on the Output Options tab, you'll see a form to set the attributes.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 37514
        • 178 Posts
        Thanks Bob, that's right, but how are these image TV Input Options meant to work?

        For instance, as you say for a given image TV you can in the Input Options set the class, id, dimensions and alt text: but I want these values to be unique per image, not per image TV.

        Classes and IDs should change as I wish them, and alt text definitely needs to be unique per image, not per image TV.

        So I tried, for instance, in this part of the Image TV output form, to specify a second TV for the alt text such as [[*alttexttv]]. That works ok, until the original image TV is used by getResources, and is outputted via a getResources template chunk, in a placeholder such as [[+tv.imageTV]].

        Does that make sense? getResources can output a TV in a placeholder, but that doesn't then manage to find the values from my second, nested TV.

        I'm saying this seems a bit inflexible, basically. Maybe there's a workaround, like using a getResources pre-hook, but that's a lot of work for what I normally do by writing

        <img ="[[*imgtv]]" alt="[[*imgalt]]" /> 


        Now I write
        [[*imgtv]]


        But it fails to output a unique [[*imgalt]] assigned in the input options when rendered by getResources templates as

        [[+tv.imgtv]]
          • 3749
          • 24,544 Posts
          Good point.

          You might try this, though I question whether it will work:

          [[!+tv.imgtv]]
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 37514
            • 178 Posts
            Quote from: BobRay at Oct 27, 2013, 01:27 AM
            Good point.

            You might try this, though I question whether it will work:

            [[!+tv.imgtv]]

            Thanks - as you suspected, no.

            I'd be really interested if you or others


            1. Need to customise Image TV standardised output with media sources
            2. Mix Image TVs with getResources templates, so can't esily customise CSS, IDs, etc for an ImageTV
            3. Have workarounds they can suggest

            As I say it seems a very un-MODX approach to force HTML output to be so predefined, so I wonder if this is something the devs might think about?
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              I don't know where your problem is coming from. If I assign a media source to a TV, then edit the TV for a resource, I get sent to the media source's directory and can upload and/or select an image. The TV's content field will only show the path within the media source's directory. If I simply put the TV tag in the resource content or a template, with no output formatting widget, I get the full path to the image (MODx base path + media source path + TV content path). For example, a media source to assets/images/quilts/ where the MODx installation is in a subdirectory called revo2210:
              /revo2210/assets/images/quilts/Bargello1.jpg
                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
                • 37514
                • 178 Posts
                Thanks Susan, that is good to know. If that's the case there is something wrong with my MODX install, as it isn't doing that: if anyone has an idea what it might be that would be helpful.
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  I may have my System Settings set to use abs URLs, since I use this installation for testing things, but in any case I've never had a Media Source-based TV not output the whole path.
                    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
                    • 37514
                    • 178 Posts
                    Thanks Susan, I've checked on another install I have and I agree the image TVs should behave this way. So one of my MODXs has a bug (I'll move that discussion to that thread).

                    That said, the Image output template seems to be somewhat inflexible in some circumstances, I wonder if it might be made more flexible. Perhaps this is less important than I thought though!
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      And that is exactly why I very rarely use the output widgets. I prefer to do things my way.
                        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