Reputation: 348
I want to show image in round shape using RoR. Please see my below image tag and help me how can i convert it into round shape.
<%= image_tag(current_user.picture_url, :width => 70,:height => 60 ) %>
Don't confused about the line "current_user.picture_url" it is fetching image url from database.
Upvotes: 0
Views: 1955
Reputation: 10251
There is not any rocket-science with Rails. It's part of css
. You can define class
in image_tag
and write your css with however style you wanted to give. Like this:
<%= image_tag current_user.picture_url ,:class=> "img-circular" %>
and in your application.css or in your view file write this:
<style> # if you are putting this code in application.css then no need to write <style> tag
.img-circular{
width: 200px;
height: 200px;
background-size: cover;
display: block;
border-radius: 100px;
-webkit-border-radius: 100px;
-moz-border-radius: 100px;
}
</style>
Note: Better to use in application.css
as you can use this class anywhere in your application to apply same style.
Upvotes: 3