Sp-dev-docs: Inconsistent results with PictureThumbnailURL from search API

Created on 17 Oct 2019  路  17Comments  路  Source: SharePoint/sp-dev-docs

Category

  • [X] Question
  • [ ] Typo
  • [ ] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

I am building an SPFx web part using search API to display news posts (see example query at the bottom of this page), but I'm finding that sometimes the "PictureThumbnailURL" managed property returns the original, full-resolution image, and other times it returns the preview URL (which is a small 400x300 pixel thumbnail) in the format /sites/mysite/_layouts/15/getpreview.ashx?guidSite=[guidhere]&guidWeb=[guidhere]&guidFile=[guidhere]&ext=jpg

My desired result: I would like to get that original banner image using search (i.e., not having to make another API call to the page itself)

And a further question: I'm also perplexed as to why different URLs are returned, and is there anything I can do to get page thumbnail images consistent?

Other things I've tried:

  • I tried creating a custom managed property to pull the "BannerImageURL" crawled property, but it returns the exact same link as PictureThumbnailURL.
  • I have also manually edited the "thumbnail image" in the Page Properties to try to relink it to the larger version of the image, but that has not seemed to make a difference.

example query:
/_api/search/query?querytext=%27*%20PromotedState=2%20(contentclass:STS_ListItem)%20AND%20contenttype:"Site%20page"%27&selectproperties=%27Title,PictureThumbnailURL,Path%27&rowlimit=50

csorest question

All 17 comments

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@wobba do you have any insight on this issue, being it's related to the search REST API?

I'll try to figure out the behavior for this.

@corriespondent can you see if the contentclass or filetype differes on the items in question? Or is it all for modern pages for examples?

@wobba I am only pulling in modern pages (posted as news). News pages are in the same site pages library, but some show the full large image path while others show the "thumbnail" path.

@wobba As I've been trying to dig into this more, I noticed that the PictureThumbnailURL managed property is mapped to ows_AlternateThumbnailUrl, ows_EncodedAbsThumbnailUrl, and ows_DMSCoverImage. Just for kicks I've mapped managed properties to each of these crawled properties and am going to wait the however many hours or days it takes for SharePoint to start returning them. But I'm still mystified by why pages in the same Site Pages library would have different thumbnail sources!

@corriespondent if you click reindex this library it should be fairly quick to reindex. Not clicking, won't do anything of course :)

@wobba I have reindexed the libraries as well as the site collections and then left them for the weekend. (I don't know why, but sometimes managed properties seem to return quickly, while other times they seem to take a day!) In this case, however, I'm getting absolutely nothing from those three crawled properties (I mapped them to RefinableStrings). I'm completely mystified!

@corriespondent any update to share?

@wobba okay -- I realized that I also missed BannerImageUrl as a crawled property (the list view only shows the first three crawled properties), and that is the one that is returning results. Unfortunately I'm back where I started from because that crawled property returns different things -- sometimes it is the full image, sometimes it is the preview URL, and on a different (production) environment, the URL looks like "/_api/v2.1/sites/tenant..../driveItem/thumbnails/...." (from Drive?). This definitely feels less like a search API issue and more of a "how does SharePoint work with thumbnail images" issues, BUT if you can think of a way to retrieve the page banner image from the search API please let me know!

I tested this a bit and for modern pages I only got the value from the BannerImageUrl. If you have a banner this column contains the preview link for the banner image. If no banner is present, but you have an image on page, then it's a preview of that image.

The data comes from the SharePoint item, and not search per say - which just picks up values on the item.

I did find this http://blog.vitalyzhukov.ru/en/sharepoint-online-document-thumbnail which gives some params on the getpreview.ashx URL, allowing you to get what you need. Append &resolution=6 and you get the original resolution.

Similar to this report: I have a SPFx web part using search API to display news posts with image from the news modern page using "PictureThumbnailURL" managed property which has started to return image url as https:///_api/v2.1/drives/../items/.../thumbnails/0/c400x99999/content?preferNoRedirect=true instead of getpreview.ashx.
It is observed that some of the news image are not displayed with such PictureThumbnailURL; when accessed such url in seperate browser it returns _Item not found error_.
error msg

You can set the size via the thumbnails URL as well https://{tenant-name}.sharepoint.com/_api/v2.0/drive/items/{item-id}/thumbnails/{thumb-id}/{size} with docs at https://docs.microsoft.com/en-us/graph/api/driveitem-list-thumbnails?view=graph-rest-1.0

I vote to close this as there are options to get the correct thumb in a size you want from either API, and controlling what URL is stored on an item seems hard to change.

@wobba Thank you for looking into this. While I'm frustrated that I can't seem to control what is returned/stored in SP for the thumbnail, I think this at least gives me some options for using script to append the rendition/sizes when those two formats of URLs are returned.

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

@corriespondent see my latest blog post for an approach to working with thumbnails https://www.techmikael.com/2020/01/retrieving-thumbnailspreviews-for.html

Was this page helpful?
0 / 5 - 0 ratings