1

I would like to define "no results behaviour" for an image field in a view. For this, I need to obtain the dimensions of the image that would be placed there if it existed.

Below the "no results text", it says:

You may enter data from this view as per the "Replacement patterns" in the "Rewrite Results" section below.

In the "Replacement patterns", there is the entry:

[field_news_images-width] == Raw width

However if I for instance set the "no results text" to Width: [field_news_images-width], the output is just Width: instead of the expected Width: 70.

Is there anything else which has to be enabled such that the replacement patterns work here?

  • 1
    If the field is empty you can't get any data from it. You can still access the tokens of fields preceding it. Just hard code the width (surely the width can't be dynamic on the field, otherwise how do you expect to get the width of a non-existent image in any case: would it be 0?) – J. Reynolds Dec 15 '14 at 14:28
  • Ok, I would have wanted to obtain the width as specified in the image style, such that if I change the image style, the width here changes as well. But the documentation says I may use the string, so is then the documentation wrong? – user51122 Dec 15 '14 at 14:39
  • You can use the string, it is just empty. – J. Reynolds Dec 15 '14 at 14:53
  • "obtain the dimensions of the image that would be placed there if it existed" - Sorry, but how? Drupal can't read user's mind. No way to know what user would put there, if he would. The fact that now image field is limited in size does not mean it always was or it always will. and it can be different from content type to content type. – Mołot Dec 15 '14 at 15:02
  • I don't know about drupal's internals, but it could be able to find out about the image style which is set for this field, and in this case, the image style knows the final size. – user51122 Dec 15 '14 at 15:32

Your Answer

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

Browse other questions tagged or ask your own question.