-
Notifications
You must be signed in to change notification settings - Fork 314
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
Image block and post_mime_type #1604
Comments
@ethanclevenger91 agreed this would be a good thing to get working. Currently, the only way I'm aware of to create a partial match in Elasticsearch is to map this particular field with the ngram analyzer, which enables partial string matches. That could create some indexing overhead, so I'm also wondering if perhaps we could shortcut this by splitting the 'image/' string into an array of each part, so that we could exact match on just 'image' across any images regardless of format. @tlovett1 any thoughts? |
This is admin search correct @ethanclevenger91? I assume you have the Protected Content feature enabled? |
Admin - correct. I didn't have the Protected Content feature enabled, though I'm enabling it now after better understanding what it does. |
I'm working on it. |
I just ran into this - doesn't seem to be fixed in the latest version. The issue is that the plugin assumes if a string value is passed then it's a truncated / prefix mime type and if it's an array then they're fully qualified: https://github.com/10up/ElasticPress/blob/develop/includes/classes/Indexable/Post/Post.php#L907-L934 This isn't exactly reliable as the image block shows but WP will accept any combination of those truncated and fully qualified values. I've got a temporary workaround here: https://github.com/humanmade/altis-enhanced-search/pull/98/files The latter part of it will nicely handle whatever is passed to the I'll make a PR as soon as I can. |
As noted in issue 10up#1604 the image block sends a mime type value of `image` through as an array which goes against the convention this part of the query filter relied on. This update makes the filter more agnostic, working with a single string (as `wp_post_mime_type_where()` does) or an array, plus it will then separate the values into full terms and prefixes. This has the benefit of supporting almost any combination of values given in the `post_mime_type` argument and avoids the use of a `regexp` query which can be slower to run.
We can use wp_get_mime_types to check which mime types exist and search for all of them. So, for |
Describe the bug
The Gutenberg image block adds
'post_mime_type' => 'image'
to the media modal's search queries (thequery-attachments
AJAX action). The classic editor didn't add this parameter.ElasticPress translates post_mime_type to an exact match, but in
wp_post_mime_type_where()
, which WP_Query uses to parse that argument, if there's no/
in the post_mime_type, the resulting SQL wildcards the second half of the mime type, soLIKE 'image/%'
(for this specific case).While admin-side functionality isn't the default for this plugin, updating this logic would make it more seamless.
Steps to Reproduce
ep_admin_wp_query_integration
andep_ajax_wp_query_integration
Expected behavior
Image search results in the admin should be consistent.
Environment information
Additional context
Current workaround is a
pre_get_posts
filter:The text was updated successfully, but these errors were encountered: