edrich13
edrich13

Reputation: 829

how to add a src image path inside an image tag of another image rails

i want to add an image inside an image tag in rails how to do it? if i try doing the following code it says the blank.gif is not present . how to make it take the asset image part ... my blank.gif is present in asset/images

%img.sp-image{"data-src" => "#{gallery_image.image.url}", :src => "path/to/blank.gif"}/

i want to pass blank.gif in src by using something like asset_url so that it directly locates that file rather than giving the entire file path

Upvotes: 1

Views: 675

Answers (2)

Malware Skiddie
Malware Skiddie

Reputation: 318

Your source location to your file is incorrect, If your image resides in assets/images i.e the default location of images then you need not to write assets/images/image_name instead you can directly do assets/image_name.

%img.sp-image{"data-src" => "#{gallery_image.image.url}", :src => "/assets/blank.gif"}/

Upvotes: 1

Satendra
Satendra

Reputation: 6865

you can use asset_path in your HAML

%img.sp-image{:alt => "image description", :src => asset_path("blank.gif")}

Upvotes: 2

Related Questions