Posting this here as it's dependent on a filefield patch...

This adds configurable upload thumbnail sizes (ie 100x100, 300x200, 0 <- don't thumb).

It also gets rid of a little thumbnail logic quirk where only height *or* width are checked. Thus currently if you upload a 5000x50 image it doesn't get thumb'd.

Comments

Moonshine’s picture

Updated patch that checks if an image toolkit is active...

drewish’s picture

Status: Needs review » Needs work

if we're going to break the compatibility with the core functions i'd just as soon make the field the first parameter and make sure that we pass it to all the file save functions and hooks consistently.

could you move the imagefield fix into it's own issue?

Moonshine’s picture

Title: Configurable upload thumbnail size » Filefield configurable upload thumbnail size
StatusFileSize
new2.4 KB

Updated patch with $field as first parameter. Did not update "all" hooks. Will wait until until we're sure that's the best route.

This patch goes with:

#305621: Imagefield configurable upload thumbnail size

Moonshine’s picture

Status: Needs work » Needs review

Ug.. keep forgetting about status.

Nibor-1’s picture

While the patch does what it says on the tin it breaks node tokens as created with the FileField Paths module.

As a result, using the token [nid] will cause the files to be saved in a directory called [nid] .

If the FileField Paths module is working properly once the node is submitted the directory will be renamed from [nid] (or whatever tokenname you are using) to the correct nodal value (in this case the node id number).

Currently can't actually work out why :(

Nibor

Moonshine’s picture

Hmm... off hand I can't imagine how it would come from this patch. Did you trace it back to it in some way?

There won't be a NID for a new node until the node has been saved, so I think you are just seeing that Filefield Paths doesn't have this token information yet for previews.

Nibor-1’s picture

Yeah Sorry -

I had previously applied "filefield_295620.patch" as found in Call to undefined function field_file_load() and hadn't realised the functionality had been broken for a while.

Apologies if I wasted your time.

Nibor

dopry’s picture

Status: Needs review » Needs work

I do not want to break the hook_file signature under any circumstance. I like the idea of cleaning up the thumbnail behavior, but hook_file_* is in D7 core and I don't want to break compatibility between D6 and D7 by adding features or variables that will not be supported in D7's implementation.

Moonshine’s picture

StatusFileSize
new1.88 KB

How about this...

Only $file sent into the hooks, 'thumb_resolution' just rides along in the $file object if it's available. field_file_save_upload() takes in $field, which I'm assuming is "ok", otherwise we don't have enough information to get at the field instance.

Also updated the corresponding patch for Imagefield at:

#305621: Imagefield configurable upload thumbnail size

dopry’s picture

next pain in the butt nitpick.... can this be done with hook_file on insert if that is set? Type specific processing doesn't belong in file_save_upload.

Moonshine’s picture

Status: Needs work » Needs review
StatusFileSize
new1.77 KB

Reworked using a file validator... no hooks changed :)

drewish’s picture

Status: Needs review » Needs work

looking better but rather than just sticking the one setting in there i'd rather keep it generic and stick the field name in there rather than the thumbnail size. then imagefield (or what ever) can implement the file_insert hook and see what field created it.

Moonshine’s picture

StatusFileSize
new1.81 KB

reworked sending field_name and type_name into $file...

drewish’s picture

Status: Needs work » Needs review
StatusFileSize
new2.36 KB

here's more what i was thinking... i'm not sure i want to put the type in because we can determine that from the field name and i'd like to minimize what we stick in there.

Moonshine’s picture

Can we really get at the type by just knowing the field name though? The field can be in more then one type, and all we'll have available is the field name and the other parts of $file. Not sure if I'm overlooking something...

dopry’s picture

lets stick type_name in there or pass the entire field through... the extension are instance specific so type name is necessary. I'd say go for moonshines' patch.

drewish’s picture

moonshine, you can totally find the type based on the field name... names have to be unique and the can only have one type.

that said i think dopry's right on either doing the name or the whole field.

dopry’s picture

Status: Needs review » Fixed

I committed a variation to HEAD that assigns $file->field to the entire field structure. Why should we have to look it up if we already have it... php5.2 does copy on write so we should have issues with duplicating the structure in memory unless it's modified. at least I think that is true... :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.