1

I would like to add "no results" behavior to an image field displayed in Views, such that the image from an alternate field is displayed. Ie., if Image1 is empty, display Image2.

Is it possible to use an image style in the rewrite code? I'm sure I can display the second image, using something like <img src="[field_Image2]">, but how can I specify that the image be displayed using the max_height_125 image style?

1

I figured it out! What you have to do is include a copy of the second field, set to "Exclude from display" in the options, and arrange the fields such that Image2 comes before Image1 in the list. You can set the image style in the options for Image2, and that information will get carried over when Image1 is empty and gets rewritten using the behavior specified in the "No results" option. Also, you don't have to write <img src="[field_Image2]"> in the rewrite area. All you need is the token for the other field, like [field_Image2].

| 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.