Forum

Thread tagged as: Question, Problem

Using Perch Pages for Images

I have the following set of page attributes:

<perch:pages id="mainBanner" label="Main Banner For Page" type="image" divider-before="Set Image for Page" suppress="true" width="2000" bucket="banners" />
<perch:pages id="mainBanner" type="image" suppress="true" width="960" />
<perch:pages id="mainBanner" type="image" suppress="true" width="768" />
<perch:pages id="mainBanner" type="image" suppress="true" width="360" />

This creates a banner for the page, that is then accessible from within a navigation template using:

<perch:pages id="mainBanner" />

The problem I am faced with is I want to be able to access specific sizes of this attribute. e.g.:

<perch:pages id="mainBanner" width="360" />

This does not work, Perch returns only the source file - it ignores the width attribute.

Within normal .php templates this can be overcome using string manipulation (I asked a similar question a few weeks ago), however within the confines of a html navigation template strings cannot be manipulated.

Can you please advise a solution for this as I don't wish to be serving up huge banners for small cameos within a page menu system.

Tony Astley

Tony Astley 0 points

  • 4 years ago
Richard Lowe

Richard Lowe 0 points
Registered Developer

I do something similar and works ok. Shoot me down if I'm wrong but I think you need to include the crop="true" or "false" and it will be fine.

Drew McLellan

Drew McLellan 2638 points
Perch Support

The most crucial attribute us type="image". If you don't declare a field type, it gets processed as a basic text string.

Thanks guys, I'll give it a try with the correct attribute in place on Monday.