We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43864
    • 151 Posts
    Quick question, why is the code below not working? I don't get the image showed.

    <img src="[[phpthumbof? &input=`[[processTV? &myId=`[[+id]]` &myTV=`Afbeelding`]]` &options=`&w=150&h=150&zc=1`]]" class="kader" />

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

    • discuss.answer
      • 43864
      • 151 Posts
      Quote from: sitsol at Nov 22, 2013, 03:21 AM
      Quick question, why is the code below not working? I don't get the image showed.

      <img src="[[phpthumbof? &input=`[[processTV? &myId=`[[+id]]` &myTV=`Afbeelding`]]` &options=`&w=150&h=150&zc=1`]]" class="kader">

      I found it myself. The code is correct, but there's a mistake in the phpthumbof.class.php file when using different contexts. In the main context (web) everything is fine, but when using others context (f.e. french or dutch) then the code is not correct working. If context is not default, we must reset the url to default url.

      On line 222 you have this:
         public function setInput($input) {
              /* get absolute url of image */
              if (strpos($input,'/') != 0 && strpos($input,'http') != 0) {
                  $input = $this->modx->context->getOption('base_url').$input;
              } else {
                  $input = urldecode($input);
              }
      
              $hasQuery = strpos($input,'?');
              if ($hasQuery !== false) {
                  $this->options['queryString'] = substr($input,$hasQuery+1);
                  $input = substr($input,0,$hasQuery);
              }
              if (!file_exists($input) && !empty($this->config['checkRemotelyIfNotFound'])) {
                  $input = $this->modx->context->getOption('url_scheme',MODX_URL_SCHEME).$this->modx->context->getOption('http_host',MODX_HTTP_HOST).urlencode($input);
              }
      
              $this->input = $input;
              return $this->input;
          }


      We modify this by this:

          public function setInput($input) {
              /* get absolute url of image */
              if (strpos($input,'/') != 0 && strpos($input,'http') != 0) {
                  $input = $this->modx->context->getOption('base_url').$input;
              } else {
                  $input = urldecode($input);
              }
      
      								// Modified by SitSol - if context not default, we must reset the url to default url
      								// ex. /en/assets/userfiles => /assets/userfiles
      								$working_context = $this->modx->resource->get('context_key');
      								if (strcmp($working_context, "web") != 0){
      									$input = substr($input, 3);
      								}
      
      								//---- end modified SitSol
      
      
              $hasQuery = strpos($input,'?');
              if ($hasQuery !== false) {
                  $this->options['queryString'] = substr($input,$hasQuery+1);
                  $input = substr($input,0,$hasQuery);
              }
              if (!file_exists($input) && !empty($this->config['checkRemotelyIfNotFound'])) {
                  $input = $this->modx->context->getOption('url_scheme',MODX_URL_SCHEME).$this->modx->context->getOption('http_host',MODX_HTTP_HOST).urlencode($input);
              }
      
              $this->input = $input;
              return $this->input;
          }
      


      Any ideas on this are welcome.
        • 36624
        • 535 Posts
        IMHO you shouldn't loose your time in debuging phpthumbof.
        Have a look to pThumb package instead !

        more info why here : https://github.com/oo12/phpThumbOf/wiki/Thumb-War
          CTRL+SHIFT+U - Clear Cache
          CTRL+SHIFT+H - Hiding Heft Panel
          CTRL+SHIFT+N - Fast Create Resource
          CTRL+ALT+P - Preview Recource (in edit resorce window)
          CTRL+ALT+S - Save
          • 43864
          • 151 Posts
          Quote from: emmanuel at Nov 22, 2013, 05:48 AM
          IMHO you shouldn't loose your time in debuging phpthumbof.
          Have a look to pThumb package instead !

          more info why here : https://github.com/oo12/phpThumbOf/wiki/Thumb-War

          Idd, normally I use pThumb (better caching), but it was on a hosting where the php-version was to low.