Prev: Help
Next: Formula Question
From: MickB Tenerife on
Hi
I have an ASP page that calls values from an access database using the DBRW.
One of the fields is a reference to an image file, relative to the specific
record, using the ID field to identify the correct image as below

src="/photos/<%=FP_FieldVal(fp_rs,"ID")%>a.jpg"

If that image does not exist I get the normal "X" image box.
What I would like to do is :
If the image (as above) does not exist then put a default photo
"nophoto.jpg" in its place
thanks for your help
From: Ronx on
<%
if FP_FieldVal(fp_rs,"ID") = "" Then
%>
<img src="nophoto.jpg" alt="No image available">
<% Else %>
<img src="/photos/<%=FP_FieldVal(fp_rs,"ID")%>a.jpg" alt="">
<% End If %>

Note that FrontPage Design View will display both the nophoto.jpg and a
placeholder for the database image. You should also add width and height
attributes for the images.
--
Ron Symonds
Microsoft MVP (Expression Web)
http://www.rxs-enterprises.org/fp

Reply only to group - emails will be deleted unread.



"MickB Tenerife" <MickBTenerife(a)discussions.microsoft.com> wrote in message
news:F06DFA2A-8C3E-4571-9648-42DE80894C98(a)microsoft.com...
> Hi
> I have an ASP page that calls values from an access database using the
> DBRW.
> One of the fields is a reference to an image file, relative to the
> specific
> record, using the ID field to identify the correct image as below
>
> src="/photos/<%=FP_FieldVal(fp_rs,"ID")%>a.jpg"
>
> If that image does not exist I get the normal "X" image box.
> What I would like to do is :
> If the image (as above) does not exist then put a default photo
> "nophoto.jpg" in its place
> thanks for your help

From: Ronx on
Sorry - this solution is doomed to failure, it assumes the id field is empty
if the image is missing.

--
Ron Symonds
Microsoft MVP (Expression Web)
http://www.rxs-enterprises.org/fp

Reply only to group - emails will be deleted unread.



"Ronx" <ronx917(a)hotmail.com> wrote in message
news:#Q3ETQlzKHA.5348(a)TK2MSFTNGP02.phx.gbl...
> <%
> if FP_FieldVal(fp_rs,"ID") = "" Then
> %>
> <img src="nophoto.jpg" alt="No image available">
> <% Else %>
> <img src="/photos/<%=FP_FieldVal(fp_rs,"ID")%>a.jpg" alt="">
> <% End If %>
>
> Note that FrontPage Design View will display both the nophoto.jpg and a
> placeholder for the database image. You should also add width and height
> attributes for the images.
> --
> Ron Symonds
> Microsoft MVP (Expression Web)
> http://www.rxs-enterprises.org/fp
>
> Reply only to group - emails will be deleted unread.
>
>
>
> "MickB Tenerife" <MickBTenerife(a)discussions.microsoft.com> wrote in
> message news:F06DFA2A-8C3E-4571-9648-42DE80894C98(a)microsoft.com...
>> Hi
>> I have an ASP page that calls values from an access database using the
>> DBRW.
>> One of the fields is a reference to an image file, relative to the
>> specific
>> record, using the ID field to identify the correct image as below
>>
>> src="/photos/<%=FP_FieldVal(fp_rs,"ID")%>a.jpg"
>>
>> If that image does not exist I get the normal "X" image box.
>> What I would like to do is :
>> If the image (as above) does not exist then put a default photo
>> "nophoto.jpg" in its place
>> thanks for your help
>
From: Kathleen Anderson on
This can be done without script, with a little preplanning. Import the
"nophoto.jpg" into your web site, and prepopulate the database field with
its location. If a real image is available, it will be displayed, otherwise
the "nophoto.jpg" will be displayed.

--

~ Kathleen Anderson
Microsoft MVP - Expression Web
Spider Web Woman Designs
Expression Web Resources: http://www.spiderwebwoman.com/xweb/
Expression Web Wiki: http://expression-web-wiki.com/
FrontPage Resources: http://www.spiderwebwoman.com/resources/
Please reply to the newsgroup for the benefit of others


"Ronx" <ronx917(a)hotmail.com> wrote in message
news:OG$tDTlzKHA.264(a)TK2MSFTNGP05.phx.gbl...
> Sorry - this solution is doomed to failure, it assumes the id field is
> empty if the image is missing.
>
> --
> Ron Symonds
> Microsoft MVP (Expression Web)
> http://www.rxs-enterprises.org/fp
>
> Reply only to group - emails will be deleted unread.
>
>
>
> "Ronx" <ronx917(a)hotmail.com> wrote in message
> news:#Q3ETQlzKHA.5348(a)TK2MSFTNGP02.phx.gbl...
>> <%
>> if FP_FieldVal(fp_rs,"ID") = "" Then
>> %>
>> <img src="nophoto.jpg" alt="No image available">
>> <% Else %>
>> <img src="/photos/<%=FP_FieldVal(fp_rs,"ID")%>a.jpg" alt="">
>> <% End If %>
>>
>> Note that FrontPage Design View will display both the nophoto.jpg and a
>> placeholder for the database image. You should also add width and height
>> attributes for the images.
>> --
>> Ron Symonds
>> Microsoft MVP (Expression Web)
>> http://www.rxs-enterprises.org/fp
>>
>> Reply only to group - emails will be deleted unread.
>>
>>
>>
>> "MickB Tenerife" <MickBTenerife(a)discussions.microsoft.com> wrote in
>> message news:F06DFA2A-8C3E-4571-9648-42DE80894C98(a)microsoft.com...
>>> Hi
>>> I have an ASP page that calls values from an access database using the
>>> DBRW.
>>> One of the fields is a reference to an image file, relative to the
>>> specific
>>> record, using the ID field to identify the correct image as below
>>>
>>> src="/photos/<%=FP_FieldVal(fp_rs,"ID")%>a.jpg"
>>>
>>> If that image does not exist I get the normal "X" image box.
>>> What I would like to do is :
>>> If the image (as above) does not exist then put a default photo
>>> "nophoto.jpg" in its place
>>> thanks for your help
>>



From: Ronx on
I think Kathleen's solution requires a field for the image path/name in the
database. With this field, as Kathleen suggested, populate the database with
nophoto.jpg as the default value, or adapt my first post to use this field
instead of the ID field.
Without this field, you will have to check for the presence (or absence) of
the image. The script below should do this:

<%
'Check existence of image
Set fs=Server.CreateObject("Scripting.FileSystemObject")
imgnm = "/photos/" & FP_FieldVal(fp_rs,"ID") & "a.jpg"
imgnm = Server.MapPath(imgnm) 'Find disc filing system location on server
If (fs.FileExists(imgnm))=false Then
'image does not exist
%>
<img src="nophoto.jpg" alt="No image available">
<% Else %>
<img src="/photos/" & FP_FieldVal(fp_rs,"ID") & "a.jpg" alt="">
<% End If
set fs=nothing
%>


--
Ron Symonds
Microsoft MVP (Expression Web)
http://www.rxs-enterprises.org/fp

Reply only to group - emails will be deleted unread.



"Ronx" <ronx917(a)hotmail.com> wrote in message
news:OG$tDTlzKHA.264(a)TK2MSFTNGP05.phx.gbl...
> Sorry - this solution is doomed to failure, it assumes the id field is
> empty if the image is missing.
>
> --
> Ron Symonds
> Microsoft MVP (Expression Web)
> http://www.rxs-enterprises.org/fp
>
> Reply only to group - emails will be deleted unread.
>
>
>
> "Ronx" <ronx917(a)hotmail.com> wrote in message
> news:#Q3ETQlzKHA.5348(a)TK2MSFTNGP02.phx.gbl...
>> <%
>> if FP_FieldVal(fp_rs,"ID") = "" Then
>> %>
>> <img src="nophoto.jpg" alt="No image available">
>> <% Else %>
>> <img src="/photos/<%=FP_FieldVal(fp_rs,"ID")%>a.jpg" alt="">
>> <% End If %>
>>
>> Note that FrontPage Design View will display both the nophoto.jpg and a
>> placeholder for the database image. You should also add width and height
>> attributes for the images.
>> --
>> Ron Symonds
>> Microsoft MVP (Expression Web)
>> http://www.rxs-enterprises.org/fp
>>
>> Reply only to group - emails will be deleted unread.
>>
>>
>>
>> "MickB Tenerife" <MickBTenerife(a)discussions.microsoft.com> wrote in
>> message news:F06DFA2A-8C3E-4571-9648-42DE80894C98(a)microsoft.com...
>>> Hi
>>> I have an ASP page that calls values from an access database using the
>>> DBRW.
>>> One of the fields is a reference to an image file, relative to the
>>> specific
>>> record, using the ID field to identify the correct image as below
>>>
>>> src="/photos/<%=FP_FieldVal(fp_rs,"ID")%>a.jpg"
>>>
>>> If that image does not exist I get the normal "X" image box.
>>> What I would like to do is :
>>> If the image (as above) does not exist then put a default photo
>>> "nophoto.jpg" in its place
>>> thanks for your help
>>
 |  Next  |  Last
Pages: 1 2
Prev: Help
Next: Formula Question