Oct 27 2022 08:26 PM
For Office or PDF documents, the link in the result set is for the document itself - that's what we want.
For images and videos, the link goes to DispForm.aspx instead, so when clicked opens the document details.
I found a possible solution for this if we were using SharePoint Server: Make SharePoint search results link to document instead of DispForm.aspx with no iFilter
In our case, we are using SharePoint 356 online. Any idea on how to do the same there?
Thank you.
Oct 28 2022 01:08 AM - edited Oct 28 2022 01:52 AM
We have the same problem in our custom search solution. As far as I know there is no configuration change to fix this for SharePoint Online.
When a user selects a link to a dispform.aspx we first use the UniqueId to retrieve the serverRelUrl
https://<tenant>.sharepoint.com/_api/web/GetFileById('3E68DB01-1F77-4E46-8E39-1D18592DEF3A')
and then we can display the image in the browser. The performance impact is negligible since the additional request takes < 100 ms.
Oct 28 2022 01:22 AM
Oct 28 2022 01:41 AM - edited Oct 28 2022 01:53 AM
We are in a fortunate position that we have a custom solution.
Basically we show a search bar in our custom solution and use search rest api to execute the search request. We display the search results in the desired sorting sequence.
The link for images does not open the DispForm.aspx but invokes a custom JavaScript function which uses the UniqueId from the search results to invoke a get request:
https://<tenant>.sharepoint.com/_api/web/GetFileById('3E68DB01-1F77-4E46-8E39-1D18592DEF3A')
(the guid shown is the UniqueId from the search result)
The response to the GetFileById request contains the ServerRelativeUrl which is then used to display the image in the browser. Too bad we need this intermediate request. Happy coding.