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

    Is it possible to create thumbnails depending on the format of the source image?
    I would crop the landscape pictures but not the portraits one.

    I tried to create a snippet that uses two different calls of phpthumbof depending on the format of the image. It take imgUrl in parameter. itemTplCliche looks like :
    <li>
    <img src="[[getThumbnail? &imgUrl=`[[+image]]`]]" />
    </li>


    Code snippet :
    <?php
    $size = getimagesize("$param");
    $output;
    
    if ($size[0] >= $size[1])
    {
        $options = "w=640&h=340&zc=1";
        $output = $modx->runSnippet('phpthumbof',array('input' => $param, 'options' => $options));
    }
    else
    {
        $options = "w=640&h=340&bg=000000";
        $output = $modx->runSnippet('phpthumbof',array('input' => $param, 'options' => $options));
    }
    
    return $output;



    I only get a blank page as result.
    Am I making things more complex than they need to be? Thanks for any guidance you can give me!