OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.37k stars 2.38k forks source link

Media Url's not coming through on lucene queries #11837

Open stevetayloruk opened 2 years ago

stevetayloruk commented 2 years ago

Context: When using Azure Media and media picker fields along with Lucene queries via the /api/queries endpoint.

The results returned from the api do not contain the media URL's.

Expected: The urls are returned and prefixed with the CdnBaseUrl specified in media options. Just like the graphql does.

Happy to do the change if someone can point me in the right direction.

Thanks

sebastienros commented 2 years ago

The change should be done in the Media Field index class, which records the url in the lucene index. You might want to create an additional field with the usable Url and keep the current path as it (useful for building views from query results).

stevetayloruk commented 2 years ago

Hi @sebastienros,

Are you referring to this: https://github.com/OrchardCMS/OrchardCore/blob/de48dc263dcd38032fc5d18287d48894f5385a1b/src/OrchardCore.Modules/OrchardCore.Media/Indexing/MediaFieldIndexHandler.cs?

Indexing the values still doesn't come through on the api response. The queries are using "return content Items" checkbox.

Which I believe under the hood uses contentmanager to query them and as this data is not stored in the DB, it doesn't get returned. Ideally, it would be a transform/modification/middleware/filter before after they are queried and before the response.

Is my assumption correct?

Thanks

Steve

sebastienros commented 2 years ago

Looks like we should have the same alteration mechanism as GraphQL for content item api calls. Such that the media field feature could add the public url of every media in the content item.

Maybe a simpler mitigation would be to have an api to query the based media path which would include the CdnBaseUrl such that you can append the media path to it. Maybe as part of a more generic interface to implement to provide "public" information in a common endpoint (we don't want to introduce authentication)?

I am totally fine with both options being implemented though.