Forum

Thread tagged as: Addons, Events

Adding images to Events

I am using the Events app and would like to be able to add an image for each event. In the event.html I am adding my own additional field to achieve this and the guide states I need to use perch:event instead of perch:content.

With perch:content I can set the size of the image and it will create a new size of image for this asset. However i cannot use perch:content in Events (will not show on content input page).

If I use perch:events I cannot automatically resize the image from assets - width and height and crop parameters appear to be ignored. This suggests that to add an image to an Event the user will need to resize the image first and upload.

Is this correct or am I missing something?

Simon Cox

Simon Cox 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You're missing something. The field type is the same whether it's within a perch:content or perch:events template.

If you show us your code we might be able to suggest something.

Thanks Drew

<div class="vevent">
    <h2 class="summary"><perch:events id="eventTitle" /></h2>

    <p class="dtstart"><span class="value-title" title="<perch:events id="eventDateTime" format="c" />"><perch:events id="eventDateTime" format="%c" /></span></p>

    <div class="description"><perch:events id="eventDescHTML" type="textarea" editor="redactor" html="true" encode="false" /></div>

    <p class="category"><perch:events id="category_names" encode="false" /></p>

    <perch:if exists="image">
        <img src="<perch:events id="image" type="image" label="Image" width="218" height="218" crop="true" />" alt="<perch:events id="eventTitle" />" />
    </perch:if>
</div>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, that looks fine. How is it behaving, and how is that different from what you'd expect?

Image goes in - selected from assets not uploaded - and I would expect it to be resized to 218 px square. But when checking the output I am getting a full sized image (2000px square). My expectation is that selecting a larger image will create a new image resized and added to my resources folder.

Wait - now it's doing it. Two hours I just spent trouble shooting this and all it needed was me to make myself look stupid in front of Drew (easily done)!

I will go back over what i have been changing and check - page code is exactly the same but I have been deleting Asset buckets off this site.

Thank you Drew.