phpmodx

Modx. When I try to compress an image for mobile phones using pThumb, nothing happens


I recently started working with Modx and immediately a problem appeared: when I try to compress an image for mobile phones using pThumb, nothing happens. Here is my code:

[[!getImageList? 
    &tvname=`portfolio`
    &limit=`20`
    &docid=`[[++cultureKey:is=`en`:then=`11`]][[++cultureKey:is=`fr`:then=`45`]][[++cultureKey:is=`ua`:then=`12`]][[++cultureKey:is=`ru`:then=`32`]]`
    &where=`[[+param]]`
    &tpl=`@CODE: 
    <div class="swiper-slide">
      <div class="slider__img">
#######################################
        <picture>
          <source srcset="[[pthumb? &input=`[[++site_url]][[+image]]` &options=`w=100&h=200&zc=1&q=10`]]" media="(orientation: portrait)">
          <img src="[[pthumb? &input=`[[++site_url]][[+image]]` &options=`w=200&h=100&zc=1&q=10`]]" alt="[[+section]] - [[+idx]]">
        </picture>
########################################
      </div>
      <div class="slider__bottom">
        <div class="slider__text">
          <h3 class="slider__title">
            <a href="[[+link]]">[[+title]]</a>
          </h3>
          <div class="slider__description">[[+skills]]</div>
        </div>
        <a href="[[+link]]" class="slider__link">
          <img src="/img/arrow-up-right-white.svg" alt="arrow-up-right-white">
        </a>
      </div>
    </div>
    `
    ]] 

When specifying a path like img/portfolio/123.jpg everything works well, but not when using [[+image]]. The error log has this problem: [2023-12-04 20:03:36] (ERROR @ /home/i118454/public_html/lala.com/core/components/phpthumbof/model/phpthumbof.class.php: 156) [ pThumb] Resource: 2 || Image: (none)

File not found: /home/i118454/public_html/lala.com/[[+image]] *** Skipping *** (pThumb adds this part and breaks the entire path /home/i118454/public_html/). Images continue to be output, but without applying pThumb compression.

I use modx 3.0.3, php 7.4. I will be grateful for any help.

For people who understand this, perhaps this problem can be solved easily. I've already spent the whole day on this =)


Solution

  • The image placeholder is empty according to the pThumb message. Please use a template chunk for this heavily nested code instead of the @CODE binding. It is maybe just a MODX 3.0.3 parsing issue but it is much safer to use chunks.