سؤال

I'm not sure how to accomplish this.

I'd like to print out an asset, with it's digest url, by writing in a form's textarea (in this case, using textile) when creating or editing a record.

How would I go about solving this?


Update to David Sulc's answer:

It's a bit harder than just typing the image's name in a textfield. I'm going to write it inside a textarea along with more text (think a blog post). But, I'm also using textile to format the text into HTML. Probably with RedCloth like this:

<%= RedCloth.new(@post.content).to_html %>

Images in textile are written like so:

!http://www.domain.com/image.png!

This will be converted to a <img> tag, but obviously without the digest.

هل كانت مفيدة؟

المحلول

I think image_tag and image_path are what you're looking for: just pass in the name of the image you're interested in and you'll get and image tag, and the image's path, respectively. Based on the path, you should be able to extract the file digest.

If I understand your question correctly, you want to put an image's name in a text field, then later on display the image and its path and/or digest.

  • If you submit the form to the controller, use the above 2 methods to get the information you need and make them available to the view for displaying.
  • If you're doing this with AJAX, same thing: send information to the controller (the image name), get information sent back (image path), display it (image tag and digest).
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top