-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[gatsby-source-wordpress] improve linking acf fields to media nodes #2646
Conversation
…lper functions if we won't use them
…plify future isPhotoUrl checks
… to media node: - if value is photo url - find media with that url - if value is ACF Image Object - get url from image object and find media with that url
This allow for using either Image Object or Image URL in ACF fields configuration. Previously it had very specific configuration requierments that image in root acf group had to return Image URL, but image in flexible content had to return Image Object
…nObject and adjust returned value we always have to delete featured_media even if we can't find image for it
now it doesn't make assumptions about structure, so we can just pass root acf field (possibly just root entity) and don't worry about root specific structure - this allow to have repeater field in root acf field (previously it had to be nested in flexible layout, cause of specific checks that were done on root acf field).
…tead of media node this will allow easily hookup discovering and replaceing acf gallery arrays with media node arrays
Deploy preview ready! Built with commit 982f95c |
The using-wordpress site seems to be working just fine https://deploy-preview-2646--using-wordpress.netlify.com/ @sebastienfi could you review this? |
Note: I will be away from home until monday or tuesday. I just rushed this PR, bacause i had this ready. Ideally I would like to add some documentation https://www.gatsbyjs.org/packages/gatsby-source-wordpress/ about image processing when i come back. |
@pieh awesome! Lots to do with gatsby-source-wordpress so the more helpers the merrier! |
@pieh @KyleAMathews I will definitely test this PR. @pieh Could you please test the PR I submitted at the same moment ? #2648 I have tested mine against a pretty similar ACF datamodel, I'm curious to see if it works with your model as it is. I have abstracted the media checks so it applies to any JSON node, including those outside of ACF field, and improved the recursivity of the function so that a photo could be placed higher in the three. (let's say an Image in a Repeater, inside a Clone with group not seemless, ...) |
@sebastienfi For most part it does work. Just not ACF gallery. Your changes are actually similiar to mine, I just separated matching fields to images and traversing + replacing nodes to different functions and you traverse from entity root. Only thing really missing for me is support for gallery field - you can do it like that - pieh@163719f . Plus I still hit build error described in comments here - cd0eb2b#comments |
* Most of the credits goes to @pieh for a better solution that solved the same problems and widely improved code simplicity. #2646 * Made the Media lookup begin at JSON tree root instead of keeping this for ACF Field only. Changed constants names accordingly. * Making thise more generic allorws Custom Post Types to benefit from this improvements and yet unseen objects shapes. * Incorporated fix on bug mentionned here #2646 (comment) * May solve this #2587, this #2492, this #2328
Actually I found that your code was more readable so I pulled your code and build from it. Thanks a lot ! |
#2648) * Refactored featured_media map for deep nodes * Featured medias coul be nested at any level * The most certain way to have photos works with this version on the plugin is to either name the fiel featured_media or include the image as Post Object. * Fixed bug where in some case the old featured_media field was not deleted. * Update normalize.js.snap * Integrated pieh 's changes * Most of the credits goes to @pieh for a better solution that solved the same problems and widely improved code simplicity. #2646 * Made the Media lookup begin at JSON tree root instead of keeping this for ACF Field only. Changed constants names accordingly. * Making thise more generic allorws Custom Post Types to benefit from this improvements and yet unseen objects shapes. * Incorporated fix on bug mentionned here #2646 (comment) * May solve this #2587, this #2492, this #2328 * Update normalize.js.snap
Been trying to dig around the schema tree for an example on how to query various image types and other types via GraphQL (with ACF). Strings, etc. work great, I can't seem to query images though. Do you have any examples or documentation to breakdown various queries with ACF? I am using the starter and that was very helpful. Happy to open a PR against the starter README |
Have you checked out the using-wordpress example site? |
I️ have. I️ found a working query since posting this. Will close and post the query in case anyone has any questions around this.
I️ had the transformers installed. Everything was compiling fine, I️ wasn’t sure what to use as a reference to each type of media regarding their specific attributes.
…Sent from my iPhone
On Nov 12, 2017, at 4:26 PM, Kyle Mathews ***@***.***> wrote:
Have you checked out the using-wordpress example site?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
this makes matching acf fields to media nodes more flexible and adds support for ACF gallery field
it was tested with structure like this:
And this is diff of graphql schema (manually edited, exporting schema to file would be extra handy if I would know how) after applying changes in this PR - https://gist.github.com/pieh/876c8e7a47b11a3609b379e10628068c.