Get ready for BLACK FRIDAY shopping starting in

Forums

ASP

This topic is locked

Default Image Again

Posted 28 Mar 2004 08:08:41
1
has voted
28 Mar 2004 08:08:41 Charles Knight posted:
Back to getting a onpic.jpg to appear if no image is present in the database (george, you should look at adding this to your extensions).

I use this simple to show a default image if one is'nt present:

<%
Dim PicStore1
if rsMachineRecords.Fields.Item("image1".Value <> "" then
PicStore1 = rsdatabase.Fields.Item("image1".Value
Else
PicStore1 = "../nopic.jpg"
End if
%>

However if I put this in a single row table and place a repeat region on that row each row shows the image from the first record and not its own record.
Anyone any ideas on how to fix this ?

Many Thanks
C Knight

Replies

Replied 28 Mar 2004 08:36:10
28 Mar 2004 08:36:10   replied:
There is two ways you can have to display an generic image when no image exists.
1. in your database, have it set up as a default the image that you want. In access you can specify that every time a record is created it will put a default value in until you fill it.
2. When creating a query in the recordset why not set the image location as the default value.
Both will work
Replied 28 Mar 2004 09:52:40
28 Mar 2004 09:52:40 Charles Knight replied:
Can you explain the second option abit more for me ?
And do you know why the Dim function wo't work when included in a repeat function ?
Replied 28 Mar 2004 16:00:15
28 Mar 2004 16:00:15 Phil Shevlin replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
&lt;%
If rsMachineRecords.Fields.Item("image1".Value &lt;&gt; "" then
response.write (rsdatabase.Fields.Item("image1".Value)
Else
response.write ("../nopic.jpg"
End if
%&gt;
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Put the code in the img src line.
Replied 29 Mar 2004 00:17:54
29 Mar 2004 00:17:54 Charles Knight replied:
Brilliant, worked first time,
Thankyou ever so much.

One last thing, what would the string be to show the thumbnail instead of the full size image ?
Just wooried how long a page may take to load if there are lots of images.
Many Thanks once again
C Knight
Replied 29 Mar 2004 00:34:12
29 Mar 2004 00:34:12 Phil Shevlin replied:
There's a tutorial for showing the thumb:
www.dmxzone.com/showDetail.asp?TypeId=2&NewsId=3977&LinkFile=tutorials/Display_Thumbnails/index.htm

However, I do not do it that way. I use:

replace(rsMachineRecords.Fields.Item("image1".Value,".jpg","_small.jpg"

.. assuming you use the default "_small" suffix. You'll need a thumb of the nopic.jpg also.
Replied 29 Mar 2004 00:36:47
29 Mar 2004 00:36:47 Charles Knight replied:
I do use the small suffix, where in the string you gave me before does this line go
Replied 29 Mar 2004 00:43:52
29 Mar 2004 00:43:52 Phil Shevlin replied:
Are you wanting to scrap the full size images altogether? Or, are you wanting to show thumbs only if there are more than X images to display?
Replied 29 Mar 2004 00:52:59
29 Mar 2004 00:52:59 Charles Knight replied:
The page this is used on simple shows all items in a particular category. I have a single row showing ref_no, make, mode, etc, and am showing the first image from each record (each record can have six images). The image show on the page is linked to show another page which shows the full details of the machine and all of its images, which in turn are linked to show the full size image.
So to answer your question, no I don't want to scrap the full size images, because I need to display them at a later stage, but on the page were're talking about it does'nt matter.
Hope this makes sence
If its a major headache don't worry, the page works just as I want it to apart from the above issue
Many Thanks
C Knight
Replied 29 Mar 2004 01:04:01
29 Mar 2004 01:04:01 Phil Shevlin replied:
So you are saying that for the page where the above code goes, you are only interested in showing the thumb. In that case <pre id=code><font face=courier size=2 id=code> &lt;%
If rsMachineRecords.Fields.Item("image1".Value &lt;&gt; "" then
response.write (replace(rsMachineRecords.Fields.Item("image1".Value,".jpg","_small.jpg")
Else
response.write ("../nopic.jpg"
End if
%&gt;
</font id=code></pre id=code>

But you need to make a thumb-sized nopic.jpg (if it isn't already).
Replied 29 Mar 2004 02:07:41
29 Mar 2004 02:07:41 Charles Knight replied:
Works like a dream, thankyou ever so much.
I think these two pieces of code should be posted on the main dmx site, having read many of the posts here its certainly something people keep asking about.
Thanks again
C Knight

Reply to this topic