Montag, 26. August 2019

Add automaticvally a PDF icon behind PDF file link

Paste JS Script:

/* // This script automatically adds a PDF icon after a link
// Perhaps this could be expanded on to detect if the link is to a PDF file.

// $('a').after('').attr({'class':'pdf-icon'});  */


Add CSS:

/* This CSS includes a few ways of styling PDF files */

p:not(.cssonly) a[href$=".pdf"]:before {
        /* PDF file */
  width:32px;
  height:32px;
 background:url('/images/pdf.png');
  display:inline-block;
  content:' ';
  margin-right: 10px;
}

/* Add " (PDF)" text after links that go to PDFs */
a[href$=".pdf"]:after { content: " (PDF)"; }

/* If file size specified as data attribute, use that too */
a[href$=".pdf"][data-size]:after { content: " (PDF, " attr(data-size) ")"; }

html {
  font-size: 1em;
  line-height: 1.75;
  font-weight: 200;
  -webkit-font-smoothing: antialiased;
  color: #585451;
  font-family: sans-serif;
}
/* p {  background-color: gray; } */