Format rendering of links to (local) pdf files?

AI-generated summary

The discussion revolves around customizing the display of links to user-uploaded PDF files in Discourse. tophee is looking for workarounds to make these links more prominent, as they can be easily missed when attached to posts. awesomerobot suggests using CSS to style links with the class attachment that end in .pdf, which would only affect local PDFs and not externally linked one-boxed PDFs. awesomerobot confirms this approach. Meanwhile, osioke mentions a theme component that allows for inline PDF previews, which could also be a helpful solution.

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.

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

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.

And now there is a theme component that helps too @tophee :wink: