Can't fix Attachment not linking to URL

Unfortunately this is expected and not something we can easily fix and has been an issue pretty much since the beginning. I was able to reproduce in XF 1.5.

The issue arises when you insert a thumbnail. The HTML looks roughly like this:

HTML:
  <a href="{{ ATTACHMENT URL }}">
    <img src="{{ THUMBNAIL URL }}" />
  </a>

If you wrap that in another URL tag it produces invalid HTML. You can't have an <a> tag inside an <a> tag so the browser does what it can to prevent things breaking completely. It does that by ignoring the outer <a> tag essentially.

HTML:
<a href="{{ URL BB CODE }}">
  <a href="{{ ATTACHMENT URL }}">
    <img src="{{ THUMBNAIL URL }}" />
  </a>
</a>

As a workaround, I'd suggest simply inserting the full size image, resizing it to be smaller, and wrapping that in the desired URL.
 
As a workaround, I'd suggest simply inserting the full size image, resizing it to be smaller, and wrapping that in the desired URL.
Hmm, but that would cause the browser to download the full sized image - which might be a lot bigger than the thumbnail.

A better workaround might be not to use [ATTACH] at all but the thumbnail URL for [IMG] and to wrap that in [URL].

Wouldn't it be possible to check if there is a [URL] parent when parsing [ATTACH] and skip adding the link to the full image if such a parent does exist?
 
Yep that's exactly right. It would be a trade off. It's the easy workaround. Certainly you could grab the URL of the thumbnail and just use that if desired.

There may be solutions but none of them simple. I don't think the BB code renderer maintains a tree of what the current tag's parents are, for example. A better solution might be to have some form of URL attribute support for the [ATTACH] tag but we're definitely in the realms of feature request now.

The mentioned workarounds will have to be acceptable as it stands.
 
Is it possible to have the thumbnail alone visible?

Without the larger, blurry Attachments view of the same image:

1643444981500.png

In the screenshot above I chose to point at the smaller image.

IMHO people are more likely to click the larger of the two, and so, fail to realise the relevant link.
 
Top Bottom