The team is now working on the WordPress Interactivity API. This unblocks the same UX Frontity framework enabled but directly in WordPress Core, fully compatible with the new Site Editor.
However once I do this, inside images I get basically everything from my media folder, not only the one related to the parent(914).
If I just manually go the the url in my browser site.com/wp-json/wp/v2/media?parent=914, then I see everything correctly, namely only the images with parent=914.
Moreover, if I simply navigate to the browser console and type frontity.ate.source.get("/media?parent=914") i get the same response. I can basically see all media, lots and lots of entries.
So i am wondering if what I am trying to do is even possible and if yes, what am I doing wrong. I also realize that I can filter the images to get the correct ones but I don’t understand why I have to fetch 1000 images when I need 10 in that specific context.
Hopefully someone can help clarify this.
Greetings,
Nikolay
mburridge2
Hi @ni.bonev
media is an endpoint in the WP REST API, but it’s not a queryable path or link, and state.source.get() requires such a link or path (see docs here).
Instead you need to use libraries.source.api.get() and then libraries.source.populate(). (docs here and here).
Hopefully this will guide you to solving your problem, and you won’t need to define media as a postType in the postTypes array in Frontity.
Let us know how you get on with this.
1 Like
ni.bonev3
Hi @mburridge,
that was the solution. Thanks for clarifying. Should have read the documentation better.
Here is how my final code looks. Maybe it helps someone else as well.
I am trying to get the media using the above method, but I am getting below error
(node:6756) UnhandledPromiseRejectionWarning: TypeError: response.json is not a function
at Object.populate (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/populate.ts:35:27)
mburridge6
Hi @parth.nextbits
I think you need to wrap that code in an async function and then await each of the two promises.
Hope this helps.
1 Like
rborowski.shovv7
Hi,
Could you show me how you config webpack for react-image-gallery ?
I have problem with loading styles for react-image-gallery
ni.bonev8
Hey,
Last time I worked frontity we were not having the option to configure webpack so I haven’t done anything there.
I did however have issues with the styles, so I did a manual import: import GalleryStyles from "../../../node_modules/react-image-gallery/styles/css/image-gallery.css";
And then I am loading those styles on the pages where i need the gallery. {data && data.isProduct && <Global styles={css(GalleryStyles)} />}