Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If I were to save an entity programmatically with a new image field value, this image will not be assigned a focal point until the content is submitted through the UI. I wanted to ensure that we at least saved a record for the image in this case.
Comment | File | Size | Author |
---|---|---|---|
#7 | 2856988-set-default-focal-point.patch | 1.55 KB | Dave Reid |
#4 | 2856988-set-default-focal-point.patch | 1.39 KB | Dave Reid |
| |||
#2 | 2856988-set-default-focal-point.patch | 1.39 KB | Dave Reid |
Comments
Comment #2
Dave ReidHere's what saves default focal points for images on programmatic saves, and pulls out some code out of the loops because they don't need to be re-declared every time as they are the same value.
Comment #4
Dave ReidOk, the above version is for 8.x-1.0-beta4. Updated patch for 8.x-1.x
Comment #6
bleen CreditAttribution: bleen at NBCUniversal commentedThe default value should be derived from
Otherwise this looks good to me
Comment #7
Dave ReidOh, I forgot about that default value. Updated for that change, which helps with code flow a bit more now.
Comment #8
emek CreditAttribution: emek at Lund University commentedI need this functionality too and found this old issue, the patch in #7 works for me.
Comment #10
bleen CreditAttribution: bleen at NBCUniversal commentedI made a tiny change by using the short hand ternary operator:
but otherwise ... this should have gone in a LONG time ago. Thanks for sticking it back on my radar.
Comment #11
chr.fritschThis breaks the integration with default content 😕
So before we were able to import focal_points by the default_content module. Now the default content gets imported but the x and y properties are getting overwritten then.
Comment #12
bleen CreditAttribution: bleen at NBCUniversal commented@chr.fritsch ... would you create a new issue with exact steps to reproduce?