0

We've got some categories being output using gwcode catmenu (http://gwcode.com/add-ons/gwcode-catmenu/documentation) but can't seem to find a way of outputting a certain image size (based on image manipulations setup in the file upload preferences),

The code is as follows:

 {exp:gwcode_catmenu cat_url_title="{segment_2}" active_branch_only="yes" depth="1" style="linear"}
    <li>
      <span class="product-text"><h2>{cat_name}</h2></span> 
      <span class="product-image"><img src="{cat_image}" alt="{cat_name}" /></span>
    </li>
 {/exp:gwcode_catmenu}

This works, but outputs the original image size, we want to do something like:

 {exp:gwcode_catmenu cat_url_title="{segment_2}" active_branch_only="yes" depth="1" style="linear"}
    <li>
      <span class="product-text"><h2>{cat_name}</h2></span> 
      <span class="product-image"><img src="{cat_image:small}" alt="{cat_name}" /></span>
    </li>
 {/exp:gwcode_catmenu}

To output the small version of the image, any ideas?

1 Answer 1

1

It doesn't look like GWcode CatMenu currently supports calling alternate versions of category images, but you could do this in a really quick plugin pretty easily. Your key function would look something like this:

function get_size()
{
    $image = ee()->TMPL->fetch_param('image');
    $size = ee()->TMPL->fetch_param('size');
    $pos = strrpos($image, '/');
    if($pos !== false)
    {
        $image = substr_replace($image, '/_'.$size.'/', $pos, 1);
    }
    return $image;
}

So your plugin in the template might look like:

{exp:my_plugin:get_size image="{cat_image}" size="{small}"}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.