How to use image_tag with bootstrap class: "img-responsive"? Chapter 11

The reason I am asking the question is to help me with a very annoying syntax error. I'm using chapter 11, so I can create a blog section on my new site with images, everything works apart from when I try to add a class: "img-responsive" to that line.

<%= image_tag image_article.picture.url if image_article.picture? %>

      

I just can't figure out the correct syntax for adding a class: "img-responsive".

The image loads fine, but it breaks out of the col-md-6 container and displays the full image splitting the page layout, so it all works locally separate from when I try to add the class: "img-responsive" in parentheses or brackets each the way i am trying to minimize the application so i'm stuck. I searched for other solutions, I found a gem that works with carrier ...

responsive gemstone image

but it is like using a sledgehammer to crack a nut, so far all the other problems I had I figured out, but this is really annoying. I can't find anything with the carrier resizing that matches the score for responsive images, of course I can use the img compliant class?

Shaun relationship

+3


source to share


4 answers


Try to include the tag inside the brackets



<%=image_tag(image_article.picture.url, class: "img-responsive") if image_article.picture?%>

      

+5


source


Try it .. it worked for me .. instead of xyz.png, add the image name to your Assets folder.



<% = image_tag ("xyz.png", class: "img-responsive img-thumbnail img-circle")%>

+1


source


Bootstrap 4 uses class: "img-fluid" instead of "img-responsive"

Try:

<%= image_tag image_article.picture.url, class: 'img-fluid' if image_article.picture? %>

      

+1


source


Have you tried this:

<%= image_tag image_article.picture.url, class: "img-responsive" if image_article.picture? %>

      

0


source







All Articles