We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5811
    • 1,717 Posts
    Working on the next release of AjaxSerach (1.9.0), I have modified the parser to add the following modifiers.
    May be these new modifiers could be added to the official Phx plugin. Hereafter is the extract of the ajaxSearch 1.9.0 readme file.
    ==== new modifiers for the ajaxSearch Phx parser
    
        to include images in your templates, uses the possible following phx modifiers:
    
        imgwidth  : image width       -   e.g: <img src="[+as.imageArticle+]" width="[+as.imageArticle:imgwidth+]" />
            provide the image width
    
        imgheigth : image heigth      -   e.g: <img src="[+as.imageArticle+]" heigth="[+as.imageArticle:imgheigth+]" />
            provide the image height
    
        imgattr   : image attributs   -   e.g: <img src="[+as.imageArticle+]" [+as.imageArticle:imgattr+] />
            provide the image attributes as height="xxx" width="yyy"
    
        imgmaxwidth=`length`  : image max width  -   e.g: <img src="[+as.articleImage+]" width="[+as.articleImage:imgmaxwidth=`60`+]" />
            limit the width of the image to a maximum. Under this limit, keep the true width
    
        imgmaxheight=`length` : image max height -   e.g: <img src="[+as.articleImage+]" height="[+as.articleImage:imgmaxheight=`100`+]" />
            limit the height of the image to a maximum. Under this limit, keep the true height
    
        These modifiers are particularly usefull with the ajax mode to help html to determine the height of the AjaxSearch pop-up window
    


    These modifiers could be added by changing the parser class as follow:
                        case "imgwidth": list($width, $height, $type, $attr) = getimagesize($output); $output = $width; break;
                        case "imgheight": list($width, $height, $type, $attr) = getimagesize($output); $output = $height; break;
                        case "imgattr": list($width, $height, $type, $attr) = getimagesize($output); $output = $attr; break;
                        case "imgmaxwidth":
                            list($width, $height, $type, $attr) = getimagesize($output);
                            $output = ($width < intval($modifier_value[$i])) ? $width : intval($modifier_value[$i]);
                            break;
                        case "imgmaxheight":
                            list($width, $height, $type, $attr) = getimagesize($output);
                            $output = ($height < intval($modifier_value[$i])) ? $height : intval($modifier_value[$i]);
                            break;

    Tested and guarantee wink
      • 20413
      • 2,877 Posts
      THANK YOU!!
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 18209
        • 15 Posts
        Hi, I was having a problem with this script.

        I was using a template for a Ditto call ([+paginaAfbeelding+] is a TV with an image-url)
        [+phx:if=`[+paginaAfbeelding+]`:ne=``:then=`
        	<div class="samenvatting_afbeelding" style="width: [+paginaAfbeelding:imgmaxwidth=`175`+]px;">
        		<a href="[~[+id+]~]"><img src="[+paginaAfbeelding+]" border="0" width="[+paginaAfbeelding:imgmaxwidth=`175`+]" title="lees verder..."></a>
        	</div>
        `+]


        Problem was, even though I had a phx statement to check if the TV was empty, the getimagesize() function would get called no matter what.... and I would get a MODx error, stating that this function getimagesize() cannot be empty....

        I changed the code in the first post to this (just showing one case...)

        case "imgmaxwidth":
        if($output != ’’){list($width, $height, $type, $attr) = getimagesize($output);
        $output = ($width < intval($modifier_value[$i])) ? $width : intval($modifier_value[$i]);}
        break;

        Which solved my problem

        You guys probably have better If statements (!$output) or something, but I’m on a basic level php... so change it if you want....
        Glad I solved it myself, cause I was going crazy!

        still having some problems with spaces in folder names with the %20.... but gonna try to fix that myself too...