Skip to content
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

Is the "Current Entry" option coming back? #26

Closed
good-idea opened this issue Feb 25, 2021 · 7 comments
Closed

Is the "Current Entry" option coming back? #26

good-idea opened this issue Feb 25, 2021 · 7 comments

Comments

@good-idea
Copy link

The ability to select from images that are only associated with the current document is really helpful - especially for one of my clients with a massive dataset with thousands of images. Will this be re-implemented in 1.x?

For now, I've reverted to 0.4.0 because this feature is crucial for them.

@good-idea
Copy link
Author

And, I'd be happy to make a PR that does this! I'm thinking it would be more performant to traverse the document and extract all image refs instead of making another query?

@robinpyon
Copy link
Collaborator

Hey @good-idea – in all honesty, this is something that just got accidentally left behind when switching to search facets!

I'm thinking it would be more performant to traverse the document and extract all image refs instead of making another query?

That makes way more sense then what 0.4.0 currently does, which is the following GROQ query (which must be quite slow on your client's dataset with 1000s of images). Curious to know how long that lookup takes

*[
  _type == "sanity.imageAsset" && 
  defined(*[_id == $documentId && references(^._id)][0])
]

There's no getting around another query though, but recursively grabbing those image asset refs (from the provided document) and fetching those assets individually should be much faster. I'll definitely look to add this shortly!

@good-idea
Copy link
Author

Fantastic, thank you!

@robinpyon
Copy link
Collaborator

In 1.1.2, an "In use in current document" search facet is now accessible when selecting images within an existing document

It should be much faster now, as it's just recursively pulling those refs from the current document as suggested (rather than querying every single image, which was pretty mad in hindsight)

Let me know if that doesn't work out for you!

@good-idea
Copy link
Author

Love it, thank you!

@fabien
Copy link

fabien commented Apr 28, 2021

@robinpyon I'm working with an image derived productImage type (with custom fields) in an array. Is this the reason why such images are not being picked up by the In use in current document option? I presume this currently queries for image types only?

@robinpyon
Copy link
Collaborator

Hey @fabien – I wouldn't have thought that'd make a difference since the plugin is only concerned with underlying sanity.imageAsset documents

In any case, do you mind creating a new issue and pasting your schema? I'd be happy to look into this for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants