Kenji Crosland
Kenji Crosland

Reputation: 3034

Rails: Get the image src only

Does rails have a way to get JUST the src of an image as a string? I'm trying to embed the image on a third party site in javascript.

This is the general idea (widget.js.erb):

var widgetImage = new Image();
widgetImage.src = "<=% Some groovy ruby code to just get the image src as a string %>"

Any ideas?

Upvotes: 2

Views: 1171

Answers (1)

Joe Martinez
Joe Martinez

Reputation: 854

Yup, you're looking for image_path

image_path('something.png')

Upvotes: 5

Related Questions