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

    I'm building a standard extract list with getResources (1.4.2). Inside my "tpl" I have a chunk with properties and this where my problem start. I have no problem with the output except for the images:

    • I'm forced to use uncached getResources call, otherwise the images looks really strange.
    • I get duplicates of the first image for each item (text and links are still correct).

    The item template
    <li>
        [[$img &width=`200` &height=`100`]]
        <p>[[+introtext]]</p>
        <p class="more"><a href="[[+link]]">[[+linkTitle]]</a></p>
    </li>
    


    The image chunk
    <img src="[[*img:empty=`[[+img]]`:phpthumbof=`w=[[+width]]&h=[[+height]]&q=[[+quality:default=`85`]]`]]" width="[[+width]]" height="[[+height]]" />
    


    If you wonder why I'm doing this -it's because I would like to control all image tags from one single place. This way I can change the image-quality or default format for the whole website in a really fast way.

    If you have a solution please help.

    TIA // T [ed. note: tomahl last edited this post 14 years, 8 months ago.]
      • 22303 MODX Staff
      • 10,725 Posts
      Just call the embedded img chunk non-cacheable, e.g.

      [[!$img &width=`200` &height=`100`]]
        • 37032
        • 64 Posts
        Quote from: opengeek at Jan 31, 2012, 05:26 PM
        Just call the embedded img chunk non-cacheable, e.g.

        [[!$img &width=`200` &height=`100`]]

        Hi opengeek and thanks for your reply. Unfortunately your suggestion didn't work. Just to be sure I decided to try out every possible call:

        Calling getResouces uncached & chunk uncached results in: Only first item gets an image
        Calling getResouces cached & chunk uncached results in: No images at all
        Calling getResouces cached & chunk cached results in: Each item gets the first image that looks really wierd.

        Further suggestions? smiley
          • 37032
          • 64 Posts
          Btw. Calling resources uncached, how does that affect page speed/load?
            • 22303 MODX Staff
            • 10,725 Posts
            What version of MODX? If not running 2.1.5 or 2.2.0 this likely will not work like this.
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: tomahl at Feb 02, 2012, 01:39 PM
              Btw. Calling resources uncached, how does that affect page speed/load?
              It prevents any caching of the Resource, it's Template, or it's Elements, increasing the load of every request to the Resource. When cached, only the first access executes the cacheable elements of the Resource and subsequent accesses simply return the cached output.
                • 37032
                • 64 Posts
                Quote from: opengeek at Feb 02, 2012, 05:46 PM
                What version of MODX? If not running 2.1.5 or 2.2.0 this likely will not work like this.

                I'm running MODX Revolution 2.2.0-pl2 (traditional).
                  • 37032
                  • 64 Posts
                  Quote from: opengeek at Feb 02, 2012, 05:48 PM
                  Quote from: tomahl at Feb 02, 2012, 01:39 PM
                  Btw. Calling resources uncached, how does that affect page speed/load?
                  It prevents any caching of the Resource, it's Template, or it's Elements, increasing the load of every request to the Resource. When cached, only the first access executes the cacheable elements of the Resource and subsequent accesses simply return the cached output.

                  Maybe it's better to go with the normal setup than. I mean, optimal performance is more important then maintaining the chunks.