This module should only allow PDF's to be uploaded, and then run its magic. Currently it fails to validate the file as a PDF and I can upload any file type.

Once the page is submitted there is obviously a big error from ImageMagick if it cant handle the fileltype.

Comments

dman’s picture

Generally that would be managed as property of the filefield settings when the content type is configured.
I've updated the doc to reflect this.

Next add a filefield to your chosen content type and choose 'pdf_to_imagefield' as the renderer. This filefield should be configured to only accept PDF file types.

The module doesn't do any extra validation there as usually the built-in cck validation is better at handling this.

I guess an extra check - at least when you are configuring the settings - would make sense.

The Hank’s picture

Thanks for the quick reply dman.

I Understand what you are saying, and Im unsure if this is a filefield issue not, but as a default setup It cannot validate the upload.

In the settings page it has th following option:
(image wont embed, url: http://imgur.com/sNHzs)

As you can see, by default this module has set it to 'pdf' and disabled the field (good). However this simply is not working somewhere along the line and as a user its impossible to change that value even if I wanted to.

I have set up a brand new sandbox site and used the minimal options to make it work, and it wont.

To see if it was the filefield, I made another basic file upload field and it worked as it should; it validates files on the client side and when I disable javascript, it validates the file on the server side. Neither of those happen with this module.

dman’s picture

OK. That's really helpful diagnostics.
So there is some step that the built-in validation is being bypassed. That's certainly unintentional.
I'll have a look at the code to see what's triggering that.

dman’s picture

Status: Needs work » Needs review

Found it.
Took an hour or two though.
I've committed a fix to dev

It seems that when the filetype field was 'disabled' and hardwired to 'pdf' - disabling the field also stopped the form from saving the value that was in it! Did not expect that.
This field can accept pdfs, and only pdfs.
Nobody can change it.
And FAPI decides, since it's not being changed ... don't bother to remember it. :-/

In the end it seems switching from #default_value - which got lost when passing through form submission to #value - which ignores form submission, seems to do it.

This was really opaque because the 'pdf' value was always there when you looked at the settings. But it turns out it was being put there fresh each time the form was prepared. the value wasn't really being saved.

The Hank’s picture

Status: Needs review » Reviewed & tested by the community

Great work dman.

Works as expected for me at the sandbox site, both client side side and server side.

dman’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Closed (fixed)

Closing 6.x issues