2

I have a Content Type of only an Image field and I am using Views module to create a view for it as in follows

    <div style="background:url(IMAGE1_FULL_PATH.JPG)"></div>
    <div style="background:url(IMAGE2_FULL_PATH.JPG)"></div>

Using Image URL Formatter module I was able to get the image absolute URL, but using the following "rewrite rule" in Views

  <div style="background-image:url([field_banner_image]); "></div>

It outputs the URL wrapped in a

  <a></a>

or

  <span></span>

tags, how can I possibly get the pure text URL for this image?

3 Answers 3

1

Views does reject having style attributes to any of the html elements even though the style attribute is explicitly included in rewrite results of any field in the view.

The reason and workaround maybe found here: Rewrite results strips some html attribute

My recommendation is, you can write tpl for that particular field and use the output text (which will be the url in your case) to build the div or any html element around it.

0

under Rewrite Results for the image field, try checking "strip HTML tags":

If checked. all HTML tags will be stripped

0

Edit your image field, check "Strip HTML tags" and " Exclude from display". Uncheck "rewrite output". Then add a Global: Text area field and write your image token wrapped by your div structure

If you strip tags in your image field and use the same field to show your data, obviously, it will remove your div and styles properties, thats why we use it in another field

However, probably Views wont let you to use a Style attribute in your Rewrite output field, so yeah maybe use it's tpl is the best option

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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