# How to add images to pages?

**URL:** <https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224>\
**Category:** Radiant CMS\
**Created:** [August 16, 2006, 10:00pm UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224 "2006-08-16T22:00:55Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [August 16, 2006, 10:00pm UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/1 "2006-08-16T22:00:55Z")

</div>

I need to be able to upload and link to images – for use with dynamic  
pages and/or blog entries. I don’t see an obvious way to do that – am  
i just missing it? Or would I need to create it?

It’ll need the standard 2 parts: 1. upload the pic; 2. select a pic  
for use in your page.

Any suggestions?

Thanks!  
-Tom

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [August 17, 2006, 3:58am UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/2 "2006-08-17T03:58:27Z")

</div>

On 17/08/2006, at 5:00 AM, Tom W. wrote:

> I need to be able to upload and link to images – for use with dynamic  
> pages and/or blog entries. I don’t see an obvious way to do that – am  
> i just missing it? Or would I need to create it?
> 
> It’ll need the standard 2 parts: 1. upload the pic; 2. select a pic  
> for use in your page.
> 
> Any suggestions?

Tom, this feature isn’t in Radiant (yet.) but there is a patch on trac  
[1] that gets you most of the way there. I believe some other people  
are working on a more streamlined solution, but it hasn’t been  
mentioned on the mailing list in a little while, so I’m not sure what  
is happening there.

Bodhi

[1] [http://dev.radiantcms.org:9007/radiant/ticket/147](http://dev.radiantcms.org:9007/radiant/ticket/147) ignore the spam  
🙂

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [August 17, 2006, 5:20pm UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/3 "2006-08-17T17:20:35Z")

</div>

Hi,  
I did the page\_part\_types patch before, which allows having parts of  
different types.  
I’m not sure there was a huge interest at it at the time, but I use it  
for a  
site that my writers are not very computer capable.  
For that I have created a few page parts types like - a wysiwyg part, a  
asynch image upload page (for mass image upload), an event part, a one  
image upload part and a tags part.  
If you are interested and if that seems to answer your need you can  
write  
back to me, at the moment there is no patch for the 0.5 version.  
Dror

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [August 18, 2006, 9:40am UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/4 "2006-08-18T09:40:12Z")

</div>

bodhi wrote:

> On 18/08/2006, at 12:20 AM, dror tirosh wrote:
> 
> > Hi,  
> > I did the page\_part\_types patch before, which allows having parts of  
> > different types.  
> > I’m not sure there was a huge interest at it at the time, but I use it  
> > for a site that my writers are not very computer capable.
> 
> I’m using it here 🙂
> 
> > If you are interested and if that seems to answer your need you can  
> > write back to me, at the moment there is no patch for the 0.5 version.  
> > Dror
> 
> Dror, does the patch on trac not work for 0.5.2?
> 
> Bodhi

I have been using this a lot as well. The patch fails with 0.5.2, but I  
think it is something minor to fix (I ran a bunch of patches at once, so  
I am not real clear). In any case I have it working.

I do have one problem, when one chooses a attachment part\_type, but does  
not upload an attachtement, I get an error. The if params[:file] should  
take care of this, but does not seem to.

This idea makes Radiant into an even more flexible system. I just  
created a site with a gallery, using this. Each image is it’s own page,  
a child of the gallery itself. This allows me to use the normal Radius  
tags and makes setup a snap.

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [August 18, 2006, 6:37am UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/5 "2006-08-18T06:37:38Z")

</div>

On 18/08/2006, at 12:20 AM, dror tirosh wrote:

> Hi,  
> I did the page\_part\_types patch before, which allows having parts of  
> different types.  
> I’m not sure there was a huge interest at it at the time, but I use it  
> for a site that my writers are not very computer capable.

I’m using it here 🙂

> If you are interested and if that seems to answer your need you can  
> write back to me, at the moment there is no patch for the 0.5 version.  
> Dror

Dror, does the patch on trac not work for 0.5.2?

Bodhi

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [August 18, 2006, 7:18pm UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/6 "2006-08-18T19:18:01Z")

</div>

Hi,  
I donÂ´t know if it works with 0.5.2 simply because I didnÂ´t try it yet,  
I  
just upgraded the rails version but still working on an old radiant  
version.  
Keith - errors like you get for not attaching a file can be easily taken  
care of in the code, the code youÂ´re using is more of an example then  
anything else.  
IÂ´ll check the patch on 0.5.2 and send updates if needed.  
Dror

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [August 18, 2006, 11:21pm UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/7 "2006-08-18T23:21:30Z")

</div>

Hi, I installed the patch yesterday against 0.5.2 and it seemed to  
work just fine. Thanks, by the way, it looks like it should work  
great.

-Tom

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [August 19, 2006, 12:51am UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/8 "2006-08-19T00:51:21Z")

</div>

dror tirosh wrote:

> Hi,  
> I donÂ´t know if it works with 0.5.2 simply because I didnÂ´t try it yet,  
> I  
> just upgraded the rails version but still working on an old radiant  
> version.  
> Keith - errors like you get for not attaching a file can be easily taken  
> care of in the code, the code youÂ´re using is more of an example then  
> anything else.  
> IÂ´ll check the patch on 0.5.2 and send updates if needed.  
> Dror

I figured this, but have been banging my head trying to get rid of that  
particular error. Ruby and I are still getting to know one another.

I have everything else working and little remains of your code example,  
but this one is vexing me. Pointers…?

Keith

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [August 20, 2006, 10:41pm UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/9 "2006-08-20T22:41:33Z")

</div>

Hey Keith,  
Took a bit of time and it shouldn’t but I got this solution:  
In the attahcment\_part\_type.rb, line 25 (might be a bit different in  
yours),  
change the condition to:  
if params[:file] && (params[:file].original\_filename.length \> 0)

Dror

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [August 20, 2006, 10:57pm UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/10 "2006-08-20T22:57:35Z")

</div>

I also did a multiple upload in an asynch background page\_part, whcih I  
use  
afterwards to show galleries.  
This relies on the Rmagick package.  
And a small change to the routes.rb file.

in your routes.rb add:  
# Upload Routes  
map.with\_options(:controller =\> ‘admin/upload’) do |upload|  
upload.index ‘upload’,  
:action =\> ‘index’  
upload.upload ‘upload/upload’,  
:action =\> ‘upload’  
end

put the upload\_controller into app/controllers/admin  
the multiple\_upload\_part\_type into app/page\_part\_types (or whereever you  
keep them)  
and the view.rar open into app/views/admin  
Hope I didn’t forget anything  
Dror

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [August 20, 2006, 10:47pm UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/11 "2006-08-20T22:47:07Z")

</div>

dror tirosh wrote:

> Hey Keith,  
> Took a bit of time and it shouldn’t but I got this solution:  
> In the attahcment\_part\_type.rb, line 25 (might be a bit different in  
> yours),  
> change the condition to:  
> if params[:file] && (params[:file].original\_filename.length \> 0)
> 
> Dror

Thanks, I will try that out.

Keith

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [September 4, 2006, 8:33pm UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/12 "2006-09-04T20:33:15Z")

</div>

dror tirosh wrote:

> I also did a multiple upload in an asynch background page\_part, whcih I  
> use  
> afterwards to show galleries.  
> This relies on the Rmagick package.  
> And a small change to the routes.rb file.
> 
> in your routes.rb add:  
> # Upload Routes  
> map.with\_options(:controller =\> ‘admin/upload’) do |upload|  
> upload.index ‘upload’,  
> :action =\> ‘index’  
> upload.upload ‘upload/upload’,  
> :action =\> ‘upload’  
> end
> 
> put the upload\_controller into app/controllers/admin  
> the multiple\_upload\_part\_type into app/page\_part\_types (or whereever you  
> keep them)  
> and the view.rar open into app/views/admin  
> Hope I didn’t forget anything  
> Dror

A little late, but for some reason this does not work. The upload  
indicator times out and then the images are not processed…

Keith B.

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [September 4, 2006, 11:18pm UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/13 "2006-09-04T23:18:26Z")

</div>

Sorry,  
This is mainly for my own use, the script is only there for the  
page\_part\_type, any actual page\_part you use doesn’t have any script for  
it.  
But for most the code is pretty simple so you obviously figured it out  
from  
there.  
Dror

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [September 4, 2006, 9:18pm UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/14 "2006-09-04T21:18:15Z")

</div>

Once again, answered my own question: the included scripts do not  
make the thumb and large folders, these must be made or it breaks. It  
is easy to change this. Other than that, this is pretty slick.

Keith B.

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [September 5, 2006, 12:44am UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/15 "2006-09-05T00:44:33Z")

</div>

I never enocuntered this problem, and I do add or remove images quite a  
lot.  
We remove images by just taking them off the list at the top.  
I’ld be interested to see your fix.

One thing that I have to admit makes me unhappy with the code at the  
moment  
is that it all goes to the same directory, I’ld like it to go to a  
directory  
tree similar to the slug, or something of the sort. I hope I’ld get that  
done and then upload another copy of it.

Dror

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [September 5, 2006, 12:52am UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/16 "2006-09-05T00:52:34Z")

</div>

I am still getting the validation problem whenever I add or remove  
images. I am really not sure what is going on, but I think getting  
some sleep and attacking it in the morning withour stress might help.

As for the folders, I built something like that with the normal  
uploads. Each page has its own folder. With the galleries and  
seperate controller, it is a bit more difficult, but shouldn’t be a  
problem. I will see what I can do.

Another thing I would like to do, is display the images in the page  
in the admin section. This shouldn’t be a technical problem, but a  
design one. I am already showing the article images this way, so I  
just need to figure out how to best present the thumbnails.

Keith

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [September 4, 2006, 11:36pm UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/17 "2006-09-04T23:36:28Z")

</div>

I do have one question: I would like to be able to add photos once  
the gallery is started. You seem to have programmed that, but when I  
upload a second photo, I get a validation error… I will eventually  
track it down, but maybe you have already found the problem.

Dpn’t worry, I realize that this code is not quite done. I enjoy it  
nonetheless and it has helped me a lot…

Keith

---

<div class="post-metadata">

**Author:** ![tomfarm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5ac83/32.png) [@tomfarm](https://www.ruby-forum.com/u/tomfarm)\
**Post date:** [September 5, 2006, 1:00pm UTC](https://www.ruby-forum.com/t/how-to-add-images-to-pages/65224/18 "2006-09-05T13:00:12Z")

</div>

bodhi wrote:

> Tom, this feature isn’t in Radiant (yet.) but there is a patch on trac  
> [1] that gets you most of the way there. I believe some other people  
> are working on a more streamlined solution, but it hasn’t been  
> mentioned on the mailing list in a little while, so I’m not sure what  
> is happening there.
> 
> Bodhi
> 
> [1] [http://dev.radiantcms.org:9007/radiant/ticket/147](http://dev.radiantcms.org:9007/radiant/ticket/147) ignore the spam  
> 🙂

Hi,

This ticket seems to be broken in Trac. Are the files/patches available  
anywhere else?

Thanks,  
Kev
