Forums / General / Get File Icon

Get File Icon

Author Message

Daniel Scheiner

Sunday 20 August 2006 9:16:17 am

Hi!

I want to show the Icon (PDF, etc.) of a File next to a link to the full-view of the file.
(ie have the "pdf-icon", the link "test" to the file "test.pdf" and the "file-size" and at the end a "delete that file - link"

is there any way to access the file-type-icon of a file?

thanks!
=)

Kristof Coomans

Sunday 20 August 2006 12:09:42 pm

Hello Daniel

Pass the mime_type field of the content object attribute attribute of type file ( http://ez.no/doc/ez_publish/technical_manual/3_8/reference/datatypes/file ) through the mimetype_icon template operator ( http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_operators/miscellaneous/mimetype_icon ).

{$attribute.content.mime_type|mimetype_icon( 'normal', $attribute.content.mime_type )}

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Daniel Scheiner

Tuesday 22 August 2006 7:28:28 am

cool! thanks!

and how do i actually show that image? (and put it in the same line as the name?)

Claudia Kosny

Tuesday 22 August 2006 1:45:00 pm

Hello Daniel

the code that Kristof posted returns a valid img tag so just put it wherever you want. Usually that would be in front of wherever you output the name of the file. How you get it in the same line depends on your stylesheet.
Example:
<a href="link to your file"> {$node.data_map.file.content.mime_type|mimetype_icon($icon_size)} {$node.data_map.file.content.original_filename}
</a>

This example assumes that your node has an attribute of datatype file which is called file.

If you need more information first check the links provided by Kristof -they should tell you everything you need to know. Also have a look at some of the templates for files, the most useful for me were the ezbinaryfile.tpl in the folder datatypes.

Greetings from Luxembourg

Claudia