Forum

Thread tagged as: Question

Conditionals on file mime type

Is there a way to use conditional statements with the mime type of a file?

I thought I had it working with the following:

<perch:if id="file" type="file" output="mime" match="contains" value="pdf"><i class="icon-file-pdf"></i></perch:if>

But when I try other mime types this does not work. The mime type for the file is correct in the database and is correctly output with:

<perch:content id="file" type="file" output="mime" />

eg a MS Word .docx file outputs the correct mime type "application/vnd.openxmlformats-officedocument.wordprocessingml.document"

It looks like the if statement in my code is ignoring the output="mime" and matching on the filename.

Kevin

Kevin Jackson

Kevin Jackson 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't believe so, no.

Drew

Thanks, solved it with a quick template filter to return an icon based on mime type.

Kevin