Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2007-01-21 08:54:32
- Vitruvius
- Plugin Author
- Registered: 2004-09-21
- Posts: 125
[plugin] [ORPHAN] srh_file_icon
srh_file_icon displays either the file extension (eg PDF, DOC, ZIP) or an icon image for a file. Icon images must be present in the /images directory for each file type required (eg pdf.png, doc.png — filenames should be lowercase). The icon image type (eg png, gif) can also be specified.
Version 0.1 can be downloaded here
Use: <txp:srh_file_icon displaytype=”“ imagetype=”“ />
attributes:
- displaytype – ‘text’ or ‘image’ defaults to ‘text’
- imagetype – the type of image file used for the icon, defaults to png
You can get your file icons here:
http://www.zap.org.au/documents/icons/file-icons/sample.html
This plugin is a far more basic verion of mrz_file_preview (which did a lot more and was written by someone who knows PHP).
This is my first plugin, and if you look at the code you can probably tell I don’t know PHP at all. If I keep reading my PHP book, I might get around to adding some other obvious attributes like class, width & height, alt-text etc.
shaun
Offline
Re: [plugin] [ORPHAN] srh_file_icon
sweet! I was just looking for somrething like this.
Thanks
Offline
Re: [plugin] [ORPHAN] srh_file_icon
Sounds like a nice plugin, thanks. Care to put up a sample page so we can see how it works?
Offline
#4 2007-01-22 04:17:42
- Vitruvius
- Plugin Author
- Registered: 2004-09-21
- Posts: 125
Re: [plugin] [ORPHAN] srh_file_icon
Good to hear someone can make use of this.
You can see an example of the plugin in action at this page
Unfortunately only PDFs are listed on that page – but you’ll get the idea.
The plugin is used in a form used for the listing of files. It enables the construction of the link for each file being an icon, file size and file type. That part of the file form looks like this:
<txp:file_download_link> <txp:srh_file_icon displaytype="image" /> </txp:file_download_link>
<txp:file_download_link><txp:file_download_size format="auto" decimals="0" />
<txp:srh_file_icon /></txp:file_download_link>
Shaun
Last edited by Vitruvius (2007-01-22 04:18:06)
Offline
Re: [plugin] [ORPHAN] srh_file_icon
Vitruvius – nice plugin! Thanks very much for this.
Offline
Re: [plugin] [ORPHAN] srh_file_icon
Great utility!
Note that it doesn’t seem to be consistent with capitalization. It outputs pdf.png and JPG.png. Name your icon files accordingly because some browsers are picky.
Offline
#7 2012-12-02 18:27:21
- gfdesign
- Member
- From: Argentina
- Registered: 2009-04-20
- Posts: 401
Re: [plugin] [ORPHAN] srh_file_icon
I know it’s is an orphan plugin, but anybody does know if it possible create a conditional rule when the icon image doesn’t exist?
Thanks
Offline
#8 2012-12-02 19:45:21
- gfdesign
- Member
- From: Argentina
- Registered: 2009-04-20
- Posts: 401
Re: [plugin] [ORPHAN] srh_file_icon
I reply my self. In those cases is necessary to add next lines inside <head> tags
<script type='text/javascript'>
//<![CDATA[
// Script to substitute broken images
function ImagenOk(img) {
if (!img.complete) return false;
if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) return false;
return true;
}
function RevisarImagenesRotas() {
var replacementImg = "<txp:site_url/>images/no_icon.gif";
for (var i = 0; i < document.images.length; i++) {
if (!ImagenOk(document.images[i])) {
document.images[i].src = replacementImg;
}}}
window.onload=RevisarImagenesRotas;
// ]]>
</script>
I hope it be helpful to somebody else.
Offline
Re: [plugin] [ORPHAN] srh_file_icon
Hi
icon, use CSS, no plugin:
a[href^="http://de.wikipedia.org"] {
padding:5px 16px 5px 0;background:transparent url(icons/wikipedia.gif) no-repeat center right}
a[href^="http://www.amazon.de"] {
padding:5px 16px 5px 0;background:transparent url(icons/amazon.gif) no-repeat center right}
/*a[href *="de.wikipedia.org"]{padding:5px 16px 5px 0;background:transparent url(icons/wikipedia.gif) no-repeat center right}*/
a[href$='.pdf']{padding:5px 20px 5px 0;background:transparent url(icons/icon_pdf.gif) no-repeat center right}
a[href$='.txt']{padding:5px 20px 5px 0;background:transparent url(icons/icon_txt.gif) no-repeat center right}
a[href$='.zip'],a[href$='.rar'],a[href$='.gzip'],a[href$='.bzip'],a[href$='.ace']{padding:5px 20px 5px 0;background:transparent url(icons/icon_archive.gif) no-repeat center right}
a[href ^="skype:"]{padding:5px 20px 5px 0;background:transparent url(icons/icon_skype.gif) no-repeat center right}
maybe it will help someone
Offline
#10 2012-12-03 12:17:45
- gfdesign
- Member
- From: Argentina
- Registered: 2009-04-20
- Posts: 401
Re: [plugin] [ORPHAN] srh_file_icon
Hi Susanne
I’m not sure if your solution serves when you don’t know what extension of file the user will upload. Also, the links are not to websites as you point, in my case are links pointing to files uploaded from TXP.
Anyway, many thanks for your suggestion.
Regards
Offline
Pages: 1