# Image Tag without extension

**URL:** <https://www.ruby-forum.com/t/image-tag-without-extension/118837>\
**Category:** Rails\
**Created:** [October 31, 2007, 3:09pm UTC](https://www.ruby-forum.com/t/image-tag-without-extension/118837 "2007-10-31T15:09:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [October 31, 2007, 3:09pm UTC](https://www.ruby-forum.com/t/image-tag-without-extension/118837/1 "2007-10-31T15:09:56Z")

</div>

I’ve got a Rails action that generates images from a DB, and it works  
just fine. The url is like property/pictures/234234?n=1. It spits out  
the image just fine.

However when I put this URL in an image\_tag, it works but spits out  
lots of messages about no file extensions and then adds a .png to the  
end. Lucky, the .png doesn’t break the action. Is there any way to  
force rails to allow no extension on an image URL?

Thanks,

Andrew

---

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [October 31, 2007, 3:12pm UTC](https://www.ruby-forum.com/t/image-tag-without-extension/118837/2 "2007-10-31T15:12:17Z")

</div>

![]()

Looks to be your best bet, as there are no options on image\_tag to  
ignore  
extensions.

Jason

---

<div class="post-metadata">

**Author:** ![starmaerker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@starmaerker](https://www.ruby-forum.com/u/starmaerker)\
**Post date:** [October 31, 2007, 5:36pm UTC](https://www.ruby-forum.com/t/image-tag-without-extension/118837/3 "2007-10-31T17:36:59Z")

</div>

On Oct 31, 2007, at 10:08 AM, Andrew S. wrote:

> Thanks,
> 
> Andrew

If you have frozen Rails into vendor/rails, then just change the code:

vendor/rails/actionpack/lib/action\_view/helpers/asset\_tag\_helper.rb

```
   def image_path(source)
     # unless (source.split("/").last || source).include?

```

(“.”) || source.blank?  
# ActiveSupport::Deprecation.warn(  
# "You’ve called image\_path with a source that  
doesn’t include an extension. " +  
# "In Rails 2.0, that will not result in .png  
automatically being appended. " +  
# “So you should call image\_path(‘#{source}.png’)  
instead”, caller  
# )  
# end

```
     compute_public_path(source, 'images')
   end

```

If you don’t want to do that, then you’ll have to wait for Rails 2.0.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid
