Focuspoint with Eager Loading
See original GitHub issueHi,
I’m using eager loading for retrieving some images for my gallery:
{% set employments = craft.entries({ section: 'employments', with: ['photo] }) %}
This works fine and I can see all images on my page. But whenever I try to get the focuspoints of that image:
photo[0].focusPctX
All images have the same focuspoints (50).
Whenever I try to retrieve the images without the Eager Loading function, it works fine.
Is this a known ‘bug’, or is Eager Loading just not supported by Focuspoint?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Correctly using eager loading in Plugin development
Eager loading only works when your field is a RelationField it does not work with Text fields. If you goal is to reduce...
Read more >Speed up your Craft CMS Templates with Eager Loading
Eager -Loading Elements allows you to speed up your Craft CMS templates by fetching entries from the database more efficiently.
Read more >Training and Tutorials for Craft CMS
Eager-loading elements gives you the ability to tell Craft which sub-elements you need up ... Focuspoint lets you select a focal point of...
Read more >Focus point selection - Canon EOS - Photo.net
I recently purchased a Mk IV and find the default AF Point Selection (the [ ] button on the back, to the right...
Read more >Am I doing eager loading correctly? (Eloquent) - Stack Overflow
user') it loads both the entrants and the user once you get to ->get() . When you do ->load('user') it runs another query...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I know I’m a little late, but I was able to get eager loading to work with Focus Point by adding the following method in FocusPoint_AssetElementType.php:
Hope that helps! Just added a pull request: #18
I am having issues with Eager Loading still. See these posts. aelvan/Imager-Craft#168 (comment) and #22
I am still trying to get to the bottom of it and understand exactly what is causing this to fallover, it seems as though it is getting a value from a previous asset or something?
Digging a little deeper into the database, I noticed two rows for the same asset.
I am wondering if with this fix, it is in-fact getting/selecting the wrong FocusPoint, where it has been used for a different field. Is there a way to extend this to match the right field ID?
I might be wrong in my assumption, but my PHP isn’t strong enough to test or resolve.
Thanks.