3

I have a Bean (bundle that generates blocks) which I display in one of 2 different theme regions. Either in the header, or the footer. This Bean contains an Imagefield, which is rendered through an Image Style.

I would like to be able to display the Image using a different Image Style, depending on which region the Bean is being displayed in. For example, if the Bean is being displayed in the header region, then I want the image to be rendered in style A. If it's being displayed in the footer then the image should use style B.

So - how can I select the Image Style that is used for an Image Field depending on which region the content is being displayed in?

One option would be to add another field to the Bean which would be a 'Style selector', however this introduces another step for the site owner as then then have to manually specify which style they want to use. It would be better if this were done automatically based on where the content is being displayed. However, if this can't be done, then how would I adjust the Image Style based on the value of another field?

0

You could use Viewmodes (Layout Plugin / Display suite) in order to use different image styles.

E.g. Use a view with rendered viewmode "Teaser-Big" in Header and "Teaser small" in footer and pass an context argument to the view.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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