Creating Blog Images Based On Category

  • I am trying to have the blog create an image for an article using a default set if one is not specified.


    For example if I have 3 categories of news, Live News, Recording News and General Musings. I want to have a default image used when one is not specified, changing for each category.


    <img src="<perch:if exists="image"><perch:blog id="image" type="image" width="1000" height="400" crop="true" label="Article Image" order="1" help="Image Size 1000px x 400px" /> alt="<perch:blog id="postTitle" label="Article Title" /><perch:else />/assets/images/1000x400-Placeholder.gif</perch:if>" />


    So between that perch:else statement I need some kind of <perch:if categories=live_news />/assets/images/live-news.gif</perch:if> etc


    Can anyone help?

  • drewm

    Approved the thread.
  • you should be able to do something like:

    Code
    1. <img src="<perch:if exists="image"><perch:blog id="image" type="image" width="1000" height="400" crop="true" label="Article Image" order="1" help="Image Size 1000px x 400px" /><perch:else />/assets/images/<perch:categories id="[category name]" set="[set name here]" ><perch:category id="catSlug" /></perch:categories>.gif</perch:if>" alt="" />


    Here we use the image if it exists on the blog, otherwise we use a gif from /assets/images that has the same name as the category slug.