We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37514
    • 178 Posts
    Hi there

    I have a TV for an image, with a set image source taking content from assets/images/

    When the image is selected from the TV, of course, it outputs just the part after assets/images/ - this to use the image TV, the template now needs to read

    <img src="assets/images/[[*tv_name]]" />

    I just wanted to check this is the behaviour I should expect. If so it would be useful to explain this on the Media Sources or Image TV documentation - it doesn't have to work this way, MODX knows the full path of the Image Source, so might output the full path.

    Cheers

    Jim
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Using a Media Source, the TV should return the full relative path to the image - assets/images/image.jpg. It won't display this in the TV content itself, just in the final output.
        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, in which case, my Image TVs aren't behaving properly and are not outputting the whole path.

        The media source is behaving fine in the manager, with these settings:

        basePath assets/images/
        basePathRelative Yes
        baseUrl assets/images/
        baseUrl assets/images/
        baseUrlRelative Yes
        


        Is there anything else which might be causing the problem?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I can't imagine what. If you just have the TV's raw output on a page, it doesn't have the media source path + the image path? When you edit the TV in the resource, you are sent directly to the assets/images/ directory to select and upload images, with no problems at that stage?
            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
            Quote from: sottwell at Oct 26, 2013, 06:05 AM
            I can't imagine what. If you just have the TV's raw output on a page, it doesn't have the media source path + the image path? When you edit the TV in the resource, you are sent directly to the assets/images/ directory to select and upload images, with no problems at that stage?

            That's correct on all counts.

            1. The full path is added correctly on a page / in the editor
            2. Editing the TV on the page, it correctly selects the assets/images/ directory to upload images for the image TV
            3. When outputting on a page, MODX does not render the whole TV image path, but just the part stored in the TV
              • 37514
              • 178 Posts
              Here is the chunk code for a blogpost, if it helps, [[*ZineSplashImage]] is the image TV using the media source:

                                          <div class="articleImage">
                                              <img src="assets/images/[[*ZineSplashImage]]" alt="[[*zine.ImgAlt]]"/>
                                              [[*zine2.quote:notempty=`<p class="quote">[[*zine2.quote]]</p> `]]
                                          </div>
              <!-- ZineSplashImage output [[*ZineSplashImage]] -->
              


              and here is the output from our Zine:
                                          <div class="articleImage">
                                              <img src="assets/images/zine/thumbs/troublewithshortterm.jpg" alt=""/>
                                              <p class="quote">Trouble With the Short Term</p> 
                                          </div>
              <!-- ZineSplashImage output zine/thumbs/troublewithshortterm.jpg -->
              

                • 37514
                • 178 Posts
                So not too much digging, it seems that it works fine if you change the "output" option to "image". This however means that

                 <img src="assets/images/[[*ZineSplashImage]]" alt="[[*zine.ImgAlt]]"/>


                won't work,

                [[*ZineSplashImage]]


                will output the whole thing, as in

                <img src="assets/images/path/to/image.jpg" />
                [ed. note: jim.killock last edited this post 12 years, 11 months ago.]
                  • 37514
                  • 178 Posts
                  So on another thread, Susan clarified that my image TV should be outputting the whole path, including that part defined in the media source, whether using an output template or just as default. I've checked on another install I have and this works for me. Both set ups are running Revo 2.2.6.

                  Does anyone have any ideas where the problem might be? i.e., why my Image TV is only outputting the part of the URL that is user defined, rather than media source baseURL + TV image data ?
                    • 37514
                    • 178 Posts
                    This is solved: flushing the permissions / cache seems to mean the TVs have started to behave as expected. I'm sure I did that before, but just to say this is now resolved.