Anarchic Fox on 12/6/2020 at 22:03
Hey all. Is there a way to post images so that they only become visible when their text description is clicked on? I'd like something that works the way Livejournal cuts did back in the day. I have a bunch of images to post, so I don't want to post them raw.
Anarchic Fox on 14/6/2020 at 00:09
I meant a way that doesn't involve external links. So that clicking simply shows an image, rather than loading a new page.
Kolya on 14/6/2020 at 16:54
<a onclick="(function(e){let p=e.nextSibling;if (p.style.display=='none')p.style.display='block';else p.style.display='none'})(this)">A picture of a hare in an overcoat</a><img src="https://i.imgur.com/RXxsyDa.jpg" onload="this.style.display='none'" />
You'll have to quote this post to see what I did. Just replace the image description and the image link to make your own image toggle-able.
This may not work forever, since it exploits a security hole in TTLG forum software. On the other hand it has been this way for some 15 years.
Note that the image is loaded before the user clicks, so don't post a load of huge images this way.
@Al_B: While script tags and style tags are replaced, onclick onload and onchange attributes are not. This allows running arbitrary JS on the site.
Anarchic Fox on 14/6/2020 at 17:49
Er, if this requires exploiting a security hole, I'll just use links. :sweat: Thanks for the help. :)
Al_B on 14/6/2020 at 18:20
Yeah, probably shouldn't allow that! (now disabled). I've added a new bbcode to allow you to do the same thing, however, called imghide instead of img. Use in the form [ imghide=Title text]<image url>[/imghide] or simply [ imghide]<imageurl>[/imghide] (remove the space at the start of the "[" when using it yourself). That way you'll get the following using Kolya's earlier examples:
[imghide=A picture of 3 neon colored chewbaccas posing with matching guns]https://i.imgur.com/hC4sDTX.png[/imghide]
[imghide=A picture of a hare in an overcoat]https://i.imgur.com/RXxsyDa.jpg[/imghide]
[imghide=A picture of two young potted banana plants]https://i.imgur.com/2S8d8qc.jpg[/imghide]
Anarchic Fox on 14/6/2020 at 18:27
Thanks! That's exactly what I was looking for.
Starker on 14/6/2020 at 18:53
Quote Posted by Al_B
Yeah, probably shouldn't allow that! (now disabled).
Test: <img src="https://i.imgur.com/hC4sDTX.png" width="600">
Hmm... I guess that also means no resizing images or embedding videos with html :/
Al_B on 14/6/2020 at 19:11
Nope, sorry.
ZylonBane on 16/6/2020 at 15:28
Quote Posted by Al_B
[imghide=A picture of 3 neon colored chewbaccas posing with matching guns]https://i.imgur.com/hC4sDTX.png[/imghide]
How is this different from just posting a link using the URL tag?
(
https://i.imgur.com/hC4sDTX.png) A picture of 3 neon colored chewbaccas posing with matching guns