[Seaside] Newbie: how to embed an image?
Avi Bryant
avi@beta4.com
Sat, 9 Mar 2002 13:08:18 -0800 (PST)
On Sat, 9 Mar 2002, Felix Franz wrote:
> the subject says it all, I guess a stupid question, but I don't know how
> to do it. I want a simple <IMG> in my IAComponent. My first try was to
> simply insert a
>
> <IMG src="image.jpg">
>
> with image.jpg in the "Document root"-directory. But the image can't be
> found.
Seaside doesn't expect to serve static content itself - it expects to
either be behind apache, or perhaps to have Comanche configured to serve
from a directory on a different port. Either way, the url for content
like images will not be relative to your Seaside application, it will be
something like http://yourhost/seaside-images/image.jpg.
So you have two choices - for a known src, you can just put a plain image
tag as you did above, but with an absolute url. For a dynamic src, you
can do something like
<img src="@imageName">
which will by default bind the #src attribute to the value of the
#imageName method. This is where the document root comes in - Seaside
prepends the url given as document root to the value of #src.
So, if you had
imageName
^ 'image.jpg'
and
<img src="@imageName">
and document root was set to http://yourhost/seaside-images,
you would get <img src="http://yourhost/seaside-images/image.jpg">.
Now, maybe there should be a way to serve images from within Seaside
without setting up a separate server for static content, but this has
worked out for me so far.
This all make sense?
Avi