# Image\_tag weirdness - dodgy return value - HELP PLEASE!

**URL:** <https://www.ruby-forum.com/t/image-tag-weirdness-dodgy-return-value-help-please/111454>\
**Category:** Rails\
**Created:** [August 7, 2007, 3:14pm UTC](https://www.ruby-forum.com/t/image-tag-weirdness-dodgy-return-value-help-please/111454 "2007-08-07T15:14:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [August 7, 2007, 3:14pm UTC](https://www.ruby-forum.com/t/image-tag-weirdness-dodgy-return-value-help-please/111454/1 "2007-08-07T15:14:41Z")

</div>

Can anyone help? I’ve been going round in circles for two days, tearing  
my hair out trying to show a thumbnail and a full sized version of  
pictures i have stored in my appname/data/pictures folder.

I’ve tried imagemagick/rmagick and got nowhere (several forum question  
already about that to no avail!), i’ve now gone back to just using  
image\_tag to get the damn full size picture on screen with no luck.

image\_tag “picname.jpeg”

works if i put the picture in the images folder, but i can’t make it  
navigate to my chosen pictures folder by going

image\_tag “/#{RAILS\_ROOT}/data/pictures/picname.jpeg”

- that returns the proper address with a slash in front. But, without  
the slash it starts looking from the images folder! So, i tried a  
really dirty method where i go up a couple of times from images and then  
back into my pictures folder, and then there’s a load of random looking  
digits stuck onto the file extension!

ie, this

\<%= image\_tag("…/…/data/pictures/pic32.jpeg") %\>

returns this

![Pic32](https://test.ruby-forum.com/images/../../data/pictures/pic32.jpeg?1186162587)

Where the hell does the “?1186162587” come from?

Can anyone help please, i’m desperate here and ready to start breaking  
stuff. ☹

---

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [August 7, 2007, 3:56pm UTC](https://www.ruby-forum.com/t/image-tag-weirdness-dodgy-return-value-help-please/111454/2 "2007-08-07T15:56:15Z")

</div>

Max W. wrote:

Actually, i found out about the random digits from another post (caching  
info). But that still doesn’t explain my utter lack of success in just  
showing an image. Can anyone help please?

---

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [August 7, 2007, 5:25pm UTC](https://www.ruby-forum.com/t/image-tag-weirdness-dodgy-return-value-help-please/111454/3 "2007-08-07T17:25:19Z")

</div>

Max,

Although from your rails app you can read/right anything on your  
system, your web server has limited access to you system (for good  
security reasons). I am running on a windows sytem with InstantRails,  
but the principles are the same.

You need to know what the “public” directory is for your web server.  
For my InstantRails setup thats c:\InstantRails\rails\_apps\app\_name  
\public. That means all the assets/content/images I want my web  
server to serve need to be under that directory. It looks like this  
is not the case for you.

Then my image tags are referenced with the idea the “/” is actually “c:  
\InstantRails\rails\_apps\app\_name\public”. For example, I store my  
images in c:\InstantRails\rails\_apps\app\_name\public\catalog\images.  
My image\_tags are all \<%= image\_tag /catalog/images/… %\>

So I think your problems may be solved be (a) knowing what your public  
directory is for your web server configuration, (b) putting your  
content under that directory and (c) image\_tag’ing based on that  
public directory being the root directory.

Cheers, --Kip

On Aug 7, 9:56 pm, Max W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [August 7, 2007, 7:46pm UTC](https://www.ruby-forum.com/t/image-tag-weirdness-dodgy-return-value-help-please/111454/4 "2007-08-07T19:46:14Z")

</div>

Kip wrote:

> So I think your problems may be solved be (a) knowing what your public  
> directory is for your web server configuration, (b) putting your  
> content under that directory and (c) image\_tag’ing based on that  
> public directory being the root directory.
> 
> Cheers, --Kip
> 
> On Aug 7, 9:56 pm, Max W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

ahhhhhh…god damn it 🙂

That has fixed my image\_tag problems, thanks very very much! I  
suspected i was doing something quite fundamentally wrong since i was  
having so little success. 🙂

I don’t suppose you also know about imagemagick\_tag do you? (pushing my  
luck) That still isn’t working - i now have this in my controller

imagemagick\_for ‘/data/pictures/’

and this in my view, which according to the guides i’ve seen on the net  
(such as [ImageMagick for Rails](http://vantulder.net/rails/magick/)) should make imagemagick\_tag  
look in the  
public/data/pictures  
folder, but instead makes it look (when i use it) in  
appname/imagemagick  
?

thanks a lot for your help!

---

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [August 8, 2007, 10:42am UTC](https://www.ruby-forum.com/t/image-tag-weirdness-dodgy-return-value-help-please/111454/5 "2007-08-08T10:42:16Z")

</div>

Kip wrote:

> So I guess the issue is how to have the helper save content  
> it has transformed into a place the web server can see.

Thanks kip - i thought that’s what

imagemagick\_for ‘/data/pictures/’

(in the controller) was supposed to do…

I can use imagemagick to resize pictures (ie make thumbnails) and save  
them, i just can’t use it to display anything. I can get by with using  
the normal image\_tag to display, so it’s not crucial, just annoying.

thanks again for your help with the public folder issue, that was such a  
painful sticking point but i’m back working again now which is great. 🙂

---

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [August 8, 2007, 2:09am UTC](https://www.ruby-forum.com/t/image-tag-weirdness-dodgy-return-value-help-please/111454/6 "2007-08-08T02:09:29Z")

</div>

Max, I haven’t been down this path before. I use ImageMagick but not  
its tag helper.  
I had a quick read of the docs and have a couple of things for you at  
least to think about.

1. helper has full access to the data on your machine since its part  
of your  
Rails apps. So pathname you give it need to be real system path  
names  
(not web server relative).

2. The helper is going to take your existing fille (like  
“flower.jpeg”) then  
apply some transformation.

3. It is going to have to save that transformed file somewhere so the  
web server can serve it. It looks like that it saves the resulting  
file  
in appname/imagemagick. But of course as you’ve worked out  
thats not available to your web server.

So I guess the issue is how to have the helper save content  
it has transformed into a place the web server can see.

Hope this helps a little,

–Kip

On Aug 8, 1:46 am, Max W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
