Consultor Eletrônico



Kbase 17246: How to Reference Image Files through WebSpeed
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   15/10/2008
Status: Verified

GOAL:

How to Reference Images Files through WebSpeed Applications

GOAL:

What is relative path referencing for image file?

GOAL:

What is absolution path referencing for image file?

GOAL:

How does IIS resolve image location?

GOAL:

How does Apache resolve image location?

FACT(s) (Environment):

WebSpeed 2.x
WebSpeed 3.x

FIX:

The relative method references images in relation to the location of the HTML or absolute path from the wwwroot directory.

For Progress WebSpeed, the most applicable method is using the absolute path to reference images.

Relative paths:
Relative paths show the relationship of the image to the location
of the HTML document. If your images are in a subdirectory under
the HTML document, you reference the subdirectory and the image
file. For example:

<IMG SRC="subdirectory/myonly.gif">


If your images are kept in the same directory as the HTML
document, no path is necessary. For example:

<IMG SRC="myonly.gif">

If your images are kept in a directory above the HTML document,
the example is:

<IMG SRC="../myonly.gif">

Absolute path from the wwwroot directory:

The wwwroot directory is considered the root (/) directory for
all HTML files or applications. If you want to reference an image
from a specific location, all the time with no concern of where
the HTML document is located, you use this method. For example:

Windows NT with MS IIS Web server:

The default directory for the Root/Document directory is:

drive:\Inetpub\wwwroot

There is an images subdirectory created by default:

drive:\Inetpub\wwwroot\images

HTML documents could go in the "wwwroot" directory but do
not have to. Images put into the "images" subdirectory makes
sense, for example.

To reference the image location in the HTML document,
reference from the wwwroot directory:

<IMG SRC="/images/myonly.gif">

(Notice the [/]) at the front of the path, to start at
wwwroot.)

NOTE: To test whether your absolute path is correct, you can
try the following URL from your brower:

http://www.myserver.com/images/myonly.gif

in order to see the image in the browser.

UNIX and Apache Web server:

The default directory for the Root/Document directory is:

/"path"/apache/htdocs

There is no default images directory, so here, we create
one:

/"path"/apache/htdocs/images

HTML documents go in the "htdocs" directory but do not have
to. Let's say once again that images are put into the
newly-created "images" directory.

To reference the image location in the HTML document,
reference from the htdocs directory:

<IMG SRC="/images/myonly.gif">

(Notice the [/] at the front of the path to start at
htdocs.)

The best method of referencing images for use with WebSpeed is absolute referencing. If you have images in a WebSpeed object that use relative addressing, the browser resolves the address of the image to be from the WebSpeed working directory.
For example, if you have:

<IMG SRC="myonly.gif">

in a WebSpeed web object, it is resolved to:

<IMG SRC="http://server/scripts/cgiip.exe/myonly.gif">.

This is incorrect because as WebSpeed does not send images back to the browser. Images should be sent back by the Web server.

If you have a virtual directory you need to use a syntax like:
<IMG SRC="/virtual_directory_name/subdirectory/myonly.gif">

The pathing to images is handled by HTML protocols more then by the Webspeed product. If you keep the 2 methods referenced in this solution in mind (relational or absolute from wwwroot/htdocs) you should be able to resolve the paths to images in all your applications.