Adding a TITLE to an image - Posted (1543 Views)
Retired Support Moderator
MarcelG
Posts: 2625
2625
As one could read on several HTML guidelines, the use of an ALT attribute with an image is a 'nice' thing to do:
In HTML authoring, there are very good reasons to include an alt attribute into every img element. The purpose is to specify a textual replacement for the image, to be displayed or otherwise used in place of the image.
Thus, the prime rule is: Consider what the page looks like or sounds like when images are not shown. Then, write for each image an alt text that best works as a replacement.
(Source)

I'm just wondering whether or not it would be possible to implement this feature (or something similar) into the forumcode.
The normal HTML code for such an image would be this:
<IMG SRC="image.gif" ALT="the image alt" TITLE="the image alt"> Note that I added the TITLE ánd the ALT attribute; even though the ALT attribute works for most browsers. However, some browsers will not display anything if there is no TITLE attribute.

Now, with the current forum code, we can only specify the source image. I was thinking of doing it a bit like this:
the image alt"][img]image.gif[/img][/title;"> In this way it could also be used for links, ánd normal text, so one would see a sort of 'mouse over' effect when hovering over the text or hyperlink :
the hyperlink title"][url]hyperlink[/url][/title;"> or
the alt text"]normal text[/title;">
I think that duplicating the code used for the translation of [url="hyperlink"][/url] could be used for this, but I'm not sure on how to do this. The title won't need any markup, but it would include the use of blank spaces.
However, if we would really need to create the equivalent of the real ALT and TITLE attributes of the IMG tag, it would be a lot more difficult. Perhaps the forumcode equivalent would then need to be something like this:
[img="image.gif",title="title",alt="alt"] But, that would mean a complete redo of the img tag...
Any suggestion is welcome.
(BTW ; another thing I was thinking about, was to add a bookmark code to the forumcode ; e.g. making code available to insert a referencable bookmark. (<a href="#Test"></a>).)<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Retired Support Moderator
MarcelG
Posts: 2625
2625
mmmmh...no one. making mental note to block the upcoming weekend.....thinking of excuse to give to my wife....<
Posted
Retired Support Moderator
MarcelG
Posts: 2625
2625
I was just rethinking of this, and decided to check this topic again ... I was wondering if there was someone out there who has some idea's about how to build this ?
I've taken the ReplaceURL's code, and rebuild it for the function ReplaceAcrs (replace acronyms)
So, instead of using the title attribute I've switched to the acronyms entity instead.... I know it's wrong (it's not meant for this purpose) but the effect is very much similar...dead)

Code:
Function ReplaceAcrs(ByVal strToFormat)
Dim oTag, c1Tag, c2Tag
Dim roTag, rc1Tag, rc12Tag, rc2Tag
Dim oTagPos, c1TagPos, oTagPos2, c1TagPos2
Dim Counter
Dim strArray, strArray2
Dim strFirstPart, strSecondPart

oTag = "[acr=*"
c1Tag = "*]"
c2Tag = "[/acr]"

roTag = "<acronym title="""
rc1Tag = """>"
rc2Tag = "</acronym>"

oTagPos = InStr(1, strToFormat, oTag, 1) 'Position of opening tag
c1TagPos = InStr(1, strToFormat, c1Tag, 1) 'Position of closing tag

'if opening tag and closing tag is found... If (oTagpos > 0) And (c1TagPos > 0) Then
'Split string at the opening tag
strArray = Split(strToFormat, oTag, -1, 1)

'Loop through array
For Counter = 0 To UBound(strArray)
'if the closing tag is found in the string then... If (InStr(1, strArray(Counter), c1Tag, 1) > 0) Then
'split string at the closing tag... strArray2 = Split(strArray(Counter), c1Tag, -1, 1)

strArray2(0) = replace(strArray2(0), """", " ") ' ## filter out "
strArray2(0) = replace(strArray2(0), ";", " ", 1, -1, 1) ' ## filter out ;
strArray2(0) = replace(strArray2(0), "+", " ", 1, -1, 1) ' ## filter out +
strArray2(0) = replace(strArray2(0), "(", " ", 1, -1, 1) ' ## filter out (
strArray2(0) = replace(strArray2(0), ")", " ", 1, -1, 1) ' ## filter out )
strArray2(0) = replace(strArray2(0), "*", " ", 1, -1, 1) ' ## filter out *
strArray2(0) = replace(strArray2(0), "'", " ", 1, -1, 1) ' ## filter out '
strArray2(0) = replace(strArray2(0), ">", " ", 1, -1, 1) ' ## filter out >
strArray2(0) = replace(strArray2(0), "<", " ", 1, -1, 1) ' ## filter out <
strArray2(0) = replace(strArray2(0), vbTab, " ", 1, -1, 1) ' ## filter out Tabs
strArray2(0) = replace(strArray2(0), "view-source", " ", 1, -1, 1) ' ## filter out view-source
strArray2(0) = replace(strArray2(0), "javascript", " ", 1, -1, 1) ' ## filter out javascript
strArray2(0) = replace(strArray2(0), "jscript", " ", 1, -1, 1) ' ## filter out jscript
strArray2(0) = replace(strArray2(0), "vbscript", " ", 1, -1, 1) ' ## filter out vbscript

'if the closing url tag is found in the string and
'[URL] is not found in the string then... If InStr(1, strArray2(1), c2Tag, 1) then

strFirstPart = Left(strArray2(1), InStr(1, strArray2(1), c2Tag, 1)-1)
strSecondPart = Right(strArray2(1), (Len(strArray2(1)) - Instr(1, strArray2(1), c2Tag,1) - len(c2Tag)+1))

If strFirstPart <> "" Then
If UCase(Left(strFirstPart, 5)) = "[IMG]" Then
ReplaceAcrs = ReplaceAcrs & "<acronym title=""" & strArray2(0) & """>" & strFirstPart & "</acronym>" & strSecondPart
Else
ReplaceAcrs = ReplaceAcrs & roTag & strArray2(0) & rc1Tag & strFirstPart & rc2Tag & strSecondPart
End If
Else
ReplaceAcrs = ReplaceAcrs & roTag & strArray2(0) & rc1Tag & strArray2(0) & rc2Tag & strSecondPart
End If
Else
ReplaceAcrs = ReplaceAcrs & roTag & strArray2(0) & rc1Tag & strArray2(0) & rc2Tag & strArray2(1)
End If
Else
ReplaceAcrs = ReplaceAcrs & strArray(Counter)
End If
Next
Else
ReplaceAcrs = strToFormat
End If
End Function
This seems to work ok, with this syntax:
[acr=*Text of the acronym*]bla[/acr] Now, the text bla is shown with the text Text of the acronym hovering over it with a mouseover. I've decided to use the asterisk instead of the quote, to avoid conflicts with the ReplaceURLs function, where "] is replaces by </a>.<
 
You Must enter a message