Folllowing #490470: Doesn't play nice with filefield_insert I prepared a patch to support imagefield_crop from within filefield_sources.

However, I am not sure if this is the right way to implement this. Since imagefield_crop actually MODIFIES the original file (in case of file reference). Maybe the correct implementation would be to actually clone the file object and crop that instead?

Let me know what do you think..

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Deciphered’s picture

Status: Needs review » Needs work

Hi,

I think it would make more sense to have a hook_filefield_sources_support() or something similar so other modules can be supported without the need of making a change to FileField Sources.

But this is just my opinion.

Cheers,
Deciphered.

quicksketch’s picture

My long-term hope actually has been that modules like ImageField Crop *extend* the existing Image widget in the same way that FileField Sources extends FileField. But that's all dependent on #417122: Allow drupal_alter() on Field and Widget Settings, so that modules can extend a widget without actually creating a new one entirely.

RE: "Maybe the correct implementation would be to actually clone the file object and crop that instead?".

That sounds like a safer approach generally. Actually it might be interesting to make ImageField Crop *always* maintain the original image (enabling a functionality like "recrop" after the original save). This would require ImageField Crop to store extra data though... which makes things a bit more difficult.

karljohann’s picture

Well it sure worked for me. Thanks.

akaserer’s picture

it works - great job

Alan D.’s picture

It would be best having something more generic like #541220: Allow custom filefield widgets to use filefield sources to prevent the need to have this module patched every time a new widget comes out for FileField

robbertnl’s picture

Excellent! It works!
A suggestion: a setting for enabling and disabling Upload / filebrowser / reference existing / remote url

yhager’s picture

Project: FileField Sources » Imagefield Crop

I'd like to continue tracking this in imagefield_crop issue queue

benone’s picture

is this patch really working for you guys ?
crop is working ?

when I save crop is not working, then I need to edit node, and save again. and then crop is working. what can be wrong ?

benone’s picture

oh, and I am using filefield_paths also.

YK85’s picture

subscribing

robbertnl’s picture

#8: Did you choose the crop widget for your filefield?

akaserer’s picture

the patch in this post worked.

but seems that a patch from

http://drupal.org/node/436174

was commited.

the function

function filefield_sources_elements()

was completely changed.

does anybody know how to implement the function?

akaserer’s picture

i guess changing

function filefield_sources_filefield_sources_widgets() {
  return array('filefield_widget', 'imagefield_widget');
} 

to

function filefield_sources_filefield_sources_widgets() {
  return array('filefield_widget', 'imagefield_widget', 'imagefield_crop_widget');
} 

should solve the case

thanks

akaserer’s picture

could somebody reconfirm and if its ok, commit?

yhager’s picture

@akaserer: The correct solution to this is to use the new alter hooks implemented now in CCK.

robbertnl’s picture

I can confirm #13 works for the newest release, thank you

lolmaus’s picture

Subscribing

pixelsweatshop’s picture

Sub

Fidelix’s picture

Suãwbiscruiaibingg

porg’s picture

Subscribing.

John Pitcairn’s picture

sub

perandre’s picture

It's been a while since this patch was made; are there currently any new efforts to make imagefield_sources support sources?

yhager’s picture

This patch cannot be used as it is, it needs to be rethinked.
Anyway, all of my (very little) time goes now to making a D7 release of imagefield_crop.

botris’s picture

Skip patch, use #13 works fine in D6

daveparrish’s picture

Why not add the hook in Imagefield Crop? That worked fine for me:

/**
 * Implements hook_filefield_sources_widgets().
 *
 * This returns a list of widgets that are compatible with FileField Sources.
 */
function imagefield_crop_filefield_sources_widgets() {
  return array('imagefield_crop_widget');
}
Eugene Fidelin’s picture

#25 works for me

juroon’s picture

#25 worked for me too. Simple solution to a longstanding problem.

Thanks!

Fidelix’s picture

What about D7? Any efforts on making this patch work with it?

Greg Varga’s picture

-

yhager’s picture

patches are welcome

mediamash’s picture

should add this to code, works like a charm

firfin’s picture

Assigned: Unassigned » firfin
Status: Needs work » Needs review
FileSize
556 bytes

As requested in #30 this patch contains the extra function from #25.
It is a patch against the 6.x-1.x branch.

The function itself is pretty well tested I think, if someone else could also apply it to see if it works (it does on my install.)
If this is gonna be committed, I will also write a patch for the readme.txt / documentation. The potential danger of cropping images already on server should be clarified.

daveparrish’s picture

For those who are looking for a Drupal 7 patch. I've attached a patch which works on imagefield_crop-1.x-dev. I also made a patch and issue for filefield_sources which has a necessary change in order to get these two modules to work together.

The problem I experienced was, when I used imagefield_crop with filefield_sources, the sources select on the widget would not change the form options. So, if I clicked "Remote URL" nothing would happen. This is filefield_sources functionality but the fix was to modify the imagefield_crop HTML so that it was compatible to what filefield_sources is expecting.

The filefield_sources patch fixes and issue where the transfer URL wouldn't work. The filefield_sources issue is here:
#1414958: Filefield_sources not compatible with imagefield_crop [PATCH]

daveparrish’s picture

I fixed the D7 patch so that filefield_sources no longer needs to be patched for imagefield_crop to work with filefield_sources.

ShaneOnABike’s picture

Status: Needs review » Reviewed & tested by the community

Re: #32 thanks for rolling that it works for me. Can we push this into the module pleaszzz. Then peeps can test the D7 version and push that through.

firfin’s picture

Assigned: firfin » Unassigned
joetsuihk’s picture

Status: Reviewed & tested by the community » Needs review

Thank you everyone. Committed to 7.x-1.x

http://drupalcode.org/project/imagefield_crop.git/commit/a2c696a

If anyone review #32, I can commit to 6.x branch also. Change issue status as stated.

d.sibaud’s picture

the following part of the patch was lost somewhere in the process so the dev branch 7.x-1.x does not works, putting it back let it works again:

+ /**
+ * Implements hook_filefield_sources_widgets().
+ *
+ * This returns a list of widgets that are compatible with FileField Sources.
+ */
+function imagefield_crop_filefield_sources_widgets() {
+  return array('imagefield_crop_widget');
+}
+
+/**