# Image\_tag without magic .png addition?

**URL:** <https://www.ruby-forum.com/t/image-tag-without-magic-png-addition/49403>\
**Category:** Rails\
**Created:** [December 3, 2005, 7:30pm UTC](https://www.ruby-forum.com/t/image-tag-without-magic-png-addition/49403 "2005-12-03T19:30:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fraser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6de8d8/32.png) [@fraser](https://www.ruby-forum.com/u/fraser)\
**Post date:** [December 3, 2005, 7:30pm UTC](https://www.ruby-forum.com/t/image-tag-without-magic-png-addition/49403/1 "2005-12-03T19:30:34Z")

</div>

Hi,

I have some images stored in the database and am attempting to build a  
img link to them. I would prefer to use a syntax that doesn’t restrict  
me to a hard coded path, something like this:

\<%= image\_tag(url\_for(:controller =\> ‘member\_pics’,  
:action =\> ‘show’,  
:id =\> member\_pic.id),  
:alt =\> member\_pic.member.full\_name,  
:size =\> “150x150”) %\>

However rails appends a .png automatically to my path so that the  
functional path “/member\_pics/show/4” becomes the disfunctional path  
“/member\_pics/show/4.png”.

Is there a way to disable the magic in this case (rails 0.13.1)? I have  
worked around the issue for now by building up the img tag myself …

```
 <img src="<%= url_for :controller => 'member_pics', :action =>

```

‘show’, :id =\> member\_pic.id %\>" alt="\<%= member\_pic.member.full\_name  
%\>" height=“150” width=“150”\>

Thanks,  
Fraser

---

<div class="post-metadata">

**Author:** ![fraser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6de8d8/32.png) [@fraser](https://www.ruby-forum.com/u/fraser)\
**Post date:** [December 3, 2005, 8:56pm UTC](https://www.ruby-forum.com/t/image-tag-without-magic-png-addition/49403/2 "2005-12-03T20:56:28Z")

</div>

Yeah, an :add\_suffix=\>false or something would be nice. I may run into  
this problem myself, and  
would probably use .sub(/…\*$/,’’) to remove the suffix.

csn

---

<div class="post-metadata">

**Author:** ![fraser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6de8d8/32.png) [@fraser](https://www.ruby-forum.com/u/fraser)\
**Post date:** [December 3, 2005, 9:30pm UTC](https://www.ruby-forum.com/t/image-tag-without-magic-png-addition/49403/3 "2005-12-03T21:30:21Z")

</div>

On 12/3/05, Fraser C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> :size => "150x150") %>
> 
> ```
> 
> %\>" height=“150” width=“150”\>  
> Dunno how to fix the issue, but I’d create a helper:

class ApplicationHelper  
def show\_image id  
# generate ![]()  
end  
end

And then use that.

---

<div class="post-metadata">

**Author:** ![fraser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/6de8d8/32.png) [@fraser](https://www.ruby-forum.com/u/fraser)\
**Post date:** [December 3, 2005, 10:43pm UTC](https://www.ruby-forum.com/t/image-tag-without-magic-png-addition/49403/4 "2005-12-03T22:43:16Z")

</div>

Joe Van D. wrote:

> Dunno how to fix the issue, but I’d create a helper:
> 
> class ApplicationHelper  
> def show\_image id  
> # generate ![]()  
> end  
> end

Good plan, I only have a few pages that will be displaying these images  
but it’s probably still worth a helper to keep things a little less  
wordy.
