We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36551
    • 416 Posts
    How can I select specific images from MIGX?

    I have a slideshow with a magnify zoom feature. Each slide requires a thumb, small and large (for magnify) image. I've setup MIGX to store each of these files. The slideshow is successfully populated with all the right images in all the right places using GetImages. Great. No problem.

    Now I also need to set the first images for display when the page loads. So I need to select the small and large images from the first MIGX record. So this would be the 2nd and 3rd images of the first record.

    Is this possible?

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

      • 4172
      • 5,888 Posts
      what defines your thumb, small and large images, or better, what is your MIGX - setup and what looks the json-output of your MIGX-TV (without getImageList)
      and what ist the html-output, which you would need?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 36551
        • 416 Posts
        Bruno

        Thanks for taking a look at this for me.

        Here's the output of the TV:

        [{"MIGX_id":"1","zoom-thumb-TV":"assets/images/EDITORIAL/ELLE/THUMBS/elle-175.jpg","zoom-small-TV":"assets/images/EDITORIAL/ELLE/600x600/elle-600.jpg","zoom-large-TV":"assets/images/EDITORIAL/ELLE/ZOOM/elle-1600.jpg"}]


        This is the html for the initial gallery image that needs the 2nd and 3rd image from the first record:
        <div id="gallery-container">
        
        <img src="----2nd image goes here----" id = "zoom1" class = "cloudzoom"
             data-cloudzoom =
        	 "zoomPosition: 'inside',
        	  zoomImage: '----3rd image goes here----'  " />
        


        This populates the thumbnail carousel that's working just fine:

        <div id="thumbs">
        <div class="thumbelina-but horiz left"></div>
        <ul>
        [[!getImageList?
            &tvname=`zoom-slide-show`
            &tpl=`@CODE:
        
        <li><a  href="#" class="cloudzoom-gallery"
              data-cloudzoom =
                 "useZoom: '#zoom1',
        		  zoomPosition: 'inside',
        		  image: '[[+zoom-small-TV]]',
        		  zoomImage: '[[+zoom-large-TV]]'">
        	<img src="[[+zoom-thumb-TV]]">
          </a></li>
          `]]
        </ul>
        <div class="thumbelina-but horiz right"></div>
        </div><!--thumbs-->
        </div><!--gallery container-->


          • 4172
          • 5,888 Posts
          for the first image, I think, you can just use another getImageList-call with
          &limit=`1`
          and its own tpl-chunk (or inline chunk)

          [[getImageList?
              &tvname=`zoom-slide-show`
              &tpl=`firstImageTpl`
              &limit=`1`
          ]]


          btw:
          you can call getImageList cached!
          There is no need to call it uncached.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 36551
            • 416 Posts
            Right, I understand I can get the first one. But, what I need is to display the 2nd and 3rd image.

            Thanks for the tip on the cache.
            • Does getImageList have an offset property?

              Yes, it does, it also has the ability to put the results into placeholders that you could manipulate to just display the items you want. I'm not sure how you could use the 'where' property, I don't happen to have an installation with a MIGx image list handy to examine the actual TV content.

              You might be better off using a custom table and MigxDB for such fine-tuning. [ed. note: sottwell last edited this post 9 years, 6 months ago.]
                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
                • 36551
                • 416 Posts
                Thank you!

                I guess I should RTFM. smiley

                Once I saw the raw output from the TV (thanks Bruno) and looked at the &where example in the docs (thanks Susan), it all fell into place.

                This does the trick. I'll use two Get ImageList calls, one for each image.

                [[!getImageList? &tvname=`zoom-slide-show` &where=`{"MIGX_id:=":"1"}` &tpl=`@CODE: [[+zoom-small-TV]] `]]
                  • 36551
                  • 416 Posts
                  Ok, this works, but I want to make it more bullet proof.

                  If the client changes the order in the slide show, the MIGX_id doesn't change. What I really want to use is some form of idx.

                  There is a placeholder for [[+idx]] that I can use in the output, however, I'm not sure how to access this in the &where statement. I assume that idx is generated during output so it's not in the json array.

                  Do I need to add another field along with the images for idx?

                  Not sure how to approach this. Any thoughts?

                  Update:

                  I realized since I want only the first record, I can use &limit=`1`. The order is changed, it will always choose the first record. Problem solved.

                  Having said that, this worked for me in this case, but what if really did want to access a specific position other than the first, such as the fourth record, how might I have done so. Just curious.

                  [ed. note: terrybarth last edited this post 9 years, 6 months ago.]
                  • Bruno certainly knows this better than I do, but you might need to make your own snippet to use PHP's JSON handling library. Or perhaps convert it into an array and then work with the array.
                      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
                      • 4172
                      • 5,888 Posts

                      but what if really did want to access a specific position other than the first

                      &offset=`4`


                      note:
                      there was a bug with offset, which should be fixed at the version at github
                      https://raw.githubusercontent.com/Bruno17/MIGX/master/core/components/migx/elements/snippets/getimagelist.snippet.php
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!