Hello,

Currently the latest d8 release simply does not work (it cannot save the focal points).

Attached you can find a temporary patch. However this patch solves all of my issues, it needs some work (I might implemented the save function the wrong way).

This patch includes the changes made by @bleen18 (see related issues).

I left my commenting in the patch.

Comments

harings_rob’s picture

bleen’s picture

StatusFileSize
new3.42 KB

To make it easier to figure out what has changed, here is the interdiff between the patch in the original post and the patch in #2488292: Dependency injection ... we should have some of that

bleen’s picture

I started looking at this ... first step was to confirm premise of the issue:

Currently the latest d8 release simply does not work (it cannot save the focal points).

This is not the case as far as I can tell. I have a vanilla D8 install (fairly up-to-date) and everything works fine with the latest dev release of focal_point. Were you only seeing this issue of fields not saving correctly after you applied the patch in #2488292: Dependency injection ... we should have some of that? If so, can you continue this discussion there.

If not, I have a thought about something I just noticed ... Is your field named something other than "image"? If so, this might be the issue:

/**
 * Implements hook_entity_presave().
 *
 * Saves the focal point value for the image file entity about to be saved.
 */
function focal_point_entity_presave(EntityInterface $entity) {
  if (isset($entity->field_image)) {
    foreach($entity->field_image as $item) {
      $focal_point = new FocalPoint($item->target_id);
      $focal_point->saveFocalPoint($item->focal_point);
    }
  }
}

The presave function has "field_image" hard-coded. YIKES!

harings_rob’s picture

Oops!

Must be the heat, I forgot to check the focal_point.module file.

So yes, the problem lies within the hard-coded field.

I'll change my patch tomorrow.

harings_rob’s picture

StatusFileSize
new1.07 KB

Attached you can find the new patch.
Fixing the dynamic fields.

Patch from #2488292 not included.

bleen’s picture

Title: Fixing the D8 version » Fixing hard-coded fieldname
Status: Needs review » Fixed
StatusFileSize
new1021 bytes

I made some small tweaks, but ultimately this is great. Thanks!!

bleen’s picture

... If you have a few mins to take a look at #2488292: Dependency injection ... we should have some of that that would be awesome.

Status: Fixed » Closed (fixed)

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