Maybe its just our special case. But this sounds more logical to me to set FOCAL_POINT_DEFAULT insead of empty string in hook_file_load. And it solves our specific problem with derivatives.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mkolar’s picture

Patch...

bleen’s picture

Status: Active » Needs review

Can you give me some more info about what problem it solves. I'm pretty certain there was a reason for the empty string but Ill have to give this a more thorough look.

mkolar’s picture

Hi bleen, we have the problem if you run following code, it will delete all derivatives for given file_id if there is no data in focal_point table:

$ew = entity_metadata_wrapper("your_entity", entity_id);
$file = file_load(file_id);
$ew->image->set((array) $file);
$ew->save();

This patch didn't help in the end. Solution would be to create default data in focal_point table but I don't like it.

Ok the problem with save above was because of patch.. Problem without patch is following:

- We have first entity with image which has no data in focal point and has derivatives.
- We have second entity which uses same file to its field.
- After save second entity derivatives are deleted and data filled into focal point, but we don't want this because derivatives are correct (default 50,50)
- Second save works without deletion

mkolar’s picture

mkolar’s picture

We need to be able to disable flush...

bleen’s picture

+++ b/focal_point.module
@@ -630,7 +630,7 @@ function _focal_point_supported_file($file) {
+  if (variable_get('focal_point_flush', TRUE) && $file = file_load($fid)) {

Instead of creating a new variable, can we check the file_managed table to see if the file is being used by more than one entity before flushing?

bleen’s picture

...actually, I just looked at #4 and that looks more correct to me.