View Full Version : An easy one.... hopefully....
aghill
06-23-2003, 04:58 PM
I wasn't sure what to title the thread, but hopefully it's accurate!
I'm working on a home grown Message Board/Forum App/BB system and am stuck. I'd like to the users to include images in their posts in the form of links (they can chew up someone else's disk space!); I think the easiest way to do so would be to tag the URL with "" ... "" but am not sure what the code would look like in order to say "read everything between the tags as "<img src=...... "
Any thoughts? If you know of an article that covers this or similar, that would be great! (I'd rather not take someone's code, I learn more if I'm forced to figure it out! :) )
Thanks!
http://www.4guysfromrolla.com/webtech/090199-1.shtml
aghill
06-23-2003, 08:56 PM
Thanks Kodo. I read the article.... and will reread it! I understood it, but have to figure out how to apply it to what I want to do. Thanks!
aghill
06-23-2003, 10:14 PM
Well after reading the article, I looked at the code. I decided to revisit the section that I attempted (unsucessfully) to modify previously. I think I understand it more, and am on the cusp of being able to sucessfully modify... I'm just missing one vital piece. Or at least I THINK I'm missing only one piece. So here it is....
The page to display the posts has a function to autoamatically generate hyperlinks out of text formatted like http://......
if(lcase(left(words(i), 7)) = "http://") then
if(right(words(i),1) = ".") then
words(i) = "<a href=""" & left(words(i),len(words(i))-1) & """ target=""_new"">" & left(words(i),len(words(i))-1) & "</a>."
else
words(i) = "<a href=""" & words(i) & """ target=""_new"">" & words(i) & "</a>"
end if
I figured out how to add the code to look for the "" & ""
elseif(lcase(left(words(i),5)) = "") then
if(lcase(right(words(i),6)) = "") then
words(i) = "<img src=""" &
What I can't figure out is how write the words(i) in such a manner that the first five characters are dropped ( the"") and the last 6 characters are dropped (the""). The code above shows that the end of words(i) is -1, therefore ending the statment before the period.... but how do you combine that with a specification in the beginning?
As always, help will be appreciated.
Frank
06-23-2003, 10:39 PM
I'm a bit fuzzy on this...but maybe you could try:
elseif(lcase(left(words(i),5)) = "") then
if(lcase(right(words(i),6)) = "") then
words(i) = Replace(words(i), "", "")
Words(i) = Replace(words(i), "", "")
words(i) = "<img src=""" & words(i) & """>"
I don't know exactly how you are dealing with those quote marks. You know your app better than I do, but the Replace() function will replace any instance of "" and "" with... nothing...in effect removing it from the input.
Maybe it would work like this?:
elseif lcase(left(words(i),5)) = "" AND lcase(right(words(i),6)) = "" then
words(i) = Replace(words(i), "", "")
Words(i) = Replace(words(i), "", "")
words(i) = "<img src=" & words(i) & ">"
HTH
Frank
aghill
06-24-2003, 02:39 AM
I'll give that a shot. Thanks Frank. (The quotes are just to ensure that this board doesn't think I'm actually trying to insert an image.)
I'll give it a shot in the morning, and see how that goes.
aghill
06-24-2003, 08:25 AM
Thanks Frank, that did the trick.
Frank
06-24-2003, 07:16 PM
Whoa! I made a suggestion that worked?! Wow! *Faints* ;)
hehe glad it helped! :}
aghill
06-25-2003, 07:07 AM
:D
use this ..it's easier on resources.
myimg="http://www.programmersresource.com/forum/images/vBulletin_logo.gif"
set objRegExp= New RegExp
objRegExp.Global = true
objRegExp.IgnoreCase=true
objRegExp.Pattern="\[img\]((.|\n)*?)\[\/img\]"
myimg=objRegExp.Replace(myimg,"<a href=""$1""><img src=""$1"" border=""0""></a>")
set objRegExp=nothing
response.write myimg
vBulletin v3.0.3, Copyright ©2000-2012, Jelsoft Enterprises Ltd.