Format rendering of links to (local) pdf files?

Is there an easy way (e.g. via CSS) to change the way links to user-uploaded pdf files are shown?

Apparently, pdf oneboxing is supported but I’m not sure under what conditions this is supposed to work.

Anyway, I don’t intend to re-open the discussion about pdf-oneboxing but am rather looking for viable workarounds for displaying uploaded pdfs somewhat more prominently. Apparently, there was a previous discussion on this, but it has been deleted.

A concrete example of a use case are posts created basen on a forwarded email. Here, if the email had a pdf document attached, it is easy to miss that as it appears as a simple link at the very bottom of the post, i.e. after the forwarded email’s signature, if any.

2 Likes

As far as I know oneboxing will only work on externally linked PDFs, not uploaded ones.

With CSS you could do something like

a.attachment[href$=".pdf"] {
    color: red;
    &:before {
      // The attachment icon is added using a pseudo-selector 
     // so you'd need to edit its styles here
    }
}

This applies styles to links with the class attachment only if the href ends in .pdf

11 Likes

And this excludes one-boxed pdf-links, right? In other words: the CSS code affects only local pdfs?

Correct, the oneboxes don’t have the attachment class, so it shouldn’t impact those.

3 Likes