{"id":2792,"date":"2019-10-25T16:52:08","date_gmt":"2019-10-25T14:52:08","guid":{"rendered":"https:\/\/www.itidea.nl\/?p=2792"},"modified":"2019-10-25T16:52:08","modified_gmt":"2019-10-25T14:52:08","slug":"inconvenient-getpreview-ashx","status":"publish","type":"post","link":"https:\/\/www.itidea.nl\/index.php\/inconvenient-getpreview-ashx\/","title":{"rendered":"Inconvenient getpreview.ashx"},"content":{"rendered":"\n<p>Thumbnails for pages in SharePoint Online are\ngenerated using the getpreview handler. Using this handler predefined image\nformats can be used using the &#8216;resolution&#8217; URL parameter. When this parameter\nisn&#8217;t specified resolution 0 is used: fixed width of 300px.<\/p>\n\n\n\n<p>Besides the resolution parameter two different sets of\nURL parameters can be used to get the images of the page.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"> Path parameter <\/h4>\n\n\n\n<p>The path parameter expects the path of the file to generate the thumbnail for.<br>To generate a thumbnail the full URL should look like this:<br><a href=\"https:\/\/tenant.sharepoint.com\/sites\/sitename\/_layouts\/15\/getpreview.ashx?path=https:\/\/tenant.sharepoint.com\/sites\/sitename\/SitePages\/Nederland.aspx\">https:\/\/tenant.sharepoint.com\/sites\/sitename\/_layouts\/15\/getpreview.ashx?path=https:\/\/tenant.sharepoint.com\/sites\/sitename\/SitePages\/Nederland.aspx<\/a><\/p>\n\n\n\n<p>Or the thumbnail can be retrieved from another location eg the root<br><a href=\"https:\/\/tenant.sharepoint.com\/_layouts\/15\/getpreview.ashx?path=https:\/\/tenant.sharepoint.com\/sites\/sitename\/SitePages\/Nederland.aspx\">https:\/\/tenant.sharepoint.com\/_layouts\/15\/getpreview.ashx?path=https:\/\/tenant.sharepoint.com\/sites\/sitename\/SitePages\/Nederland.aspx<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"> Guid parameters <\/h4>\n\n\n\n<p>The guid parameters are actually three parameters.<br>guidSite &#8211; the guid of the site collection without the curly brackets<br>guidWeb &#8211; the guid of the web without the curly brackets<br>guidFile &#8211; the guid of the file<br><a href=\"https:\/\/tenant.sharepoint.com\/sites\/sitename\/_layouts\/15\/getpreview.ashx?guidSite=e1420f3c716e42c6b6f0f09961dafb87&amp;guidWeb=4131dd01c11b4fcba9b2cdafcca38dbf&amp;guidFile=7711f989664e4bc080161ae4bbabba84\">https:\/\/tenant.sharepoint.com\/sites\/sitename\/_layouts\/15\/getpreview.ashx?guidSite=e1420f3c716e42c6b6f0f09961dafb87&amp;<\/a><br><a href=\"https:\/\/tenant.sharepoint.com\/sites\/sitename\/_layouts\/15\/getpreview.ashx?guidSite=e1420f3c716e42c6b6f0f09961dafb87&amp;guidWeb=4131dd01c11b4fcba9b2cdafcca38dbf&amp;guidFile=7711f989664e4bc080161ae4bbabba84\">guidWeb=4131dd01c11b4fcba9b2cdafcca38dbf&amp;<\/a><br><a href=\"https:\/\/tenant.sharepoint.com\/sites\/sitename\/_layouts\/15\/getpreview.ashx?guidSite=e1420f3c716e42c6b6f0f09961dafb87&amp;guidWeb=4131dd01c11b4fcba9b2cdafcca38dbf&amp;guidFile=7711f989664e4bc080161ae4bbabba84\">guidFile=7711f989664e4bc080161ae4bbabba84<\/a><\/p>\n\n\n\n<p>Or it can be retrieved from another location eg the root<br><a href=\"https:\/\/tenant.sharepoint.com\/_layouts\/15\/getpreview.ashx?guidSite=e1420f3c716e42c6b6f0f09961dafb87&amp;guidWeb=4131dd01c11b4fcba9b2cdafcca38dbf&amp;guidFile=7711f989664e4bc080161ae4bbabba84\">https:\/\/tenant.sharepoint.com\/_layouts\/15\/getpreview.ashx?guidSite=e1420f3c716e42c6b6f0f09961dafb87&amp;<\/a><br><a href=\"https:\/\/tenant.sharepoint.com\/_layouts\/15\/getpreview.ashx?guidSite=e1420f3c716e42c6b6f0f09961dafb87&amp;guidWeb=4131dd01c11b4fcba9b2cdafcca38dbf&amp;guidFile=7711f989664e4bc080161ae4bbabba84\">guidWeb=4131dd01c11b4fcba9b2cdafcca38dbf&amp;<\/a><br><a href=\"https:\/\/tenant.sharepoint.com\/_layouts\/15\/getpreview.ashx?guidSite=e1420f3c716e42c6b6f0f09961dafb87&amp;guidWeb=4131dd01c11b4fcba9b2cdafcca38dbf&amp;guidFile=7711f989664e4bc080161ae4bbabba84\">guidFile=7711f989664e4bc080161ae4bbabba84<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"> The inconvenience <\/h4>\n\n\n\n<p>Recently an issue arose in which no thumbnails were displayed on a page.<br>After some investigation it seemed that special characters in the URL of the page are preventing SharePoint from finding the thumbnail when using the path parameter.<br>Creating a page using the UI providing the title &#8216;Belgi\u00eb&#8217; results in a URL of belgi\u00eb.aspx. <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"137\" height=\"49\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/10\/1-inconvenient-getpreview-handler.png\" alt=\"\" class=\"wp-image-2793\"\/><figcaption>Page created<\/figcaption><\/figure><\/div>\n\n\n\n<p>Once\nan image is added to the page or the thumbnail of the page is set manually, a\nfolder is generated in the Site Assets library to store the image. When a\nspecial character is used like in the name Belgi\u00eb the folder name gets encoded\nto &#8216;BelgC3AB&#8217;.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"215\" height=\"141\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/10\/2-inconvenient-getpreview-handler.png\" alt=\"\" class=\"wp-image-2796\"\/><figcaption>Encoded folder name<\/figcaption><\/figure><\/div>\n\n\n\n<p>As long as the preview handler is used to get the thumbnail within the site the page is stored, the path parameter is working just fine and as expected, but when this thumbnail will be approached from another site it can&#8217;t be found and an error (404 Not found) is thrown.<\/p>\n\n\n\n<p>Usage within the site the page is stored results in the preview of the thumbnail:<br><a href=\"https:\/\/tenant.sharepoint.com\/sites\/sitename\/_layouts\/15\/getpreview.ashx?path=https:\/\/tenant.sharepoint.com\/sites\/sitename\/SitePages\/Belgi\u00eb.aspx\">https:\/\/tenant.sharepoint.com\/sites\/sitename\/_layouts\/15\/getpreview.ashx?path=https:\/\/tenant.sharepoint.com\/sites\/sitename\/SitePages\/Belgi\u00eb.aspx<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"301\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/10\/3-inconvenient-getpreview-handler-1024x301.png\" alt=\"\" class=\"wp-image-2795\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/10\/3-inconvenient-getpreview-handler-1024x301.png 1024w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/10\/3-inconvenient-getpreview-handler-300x88.png 300w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/10\/3-inconvenient-getpreview-handler-768x226.png 768w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/10\/3-inconvenient-getpreview-handler-940x277.png 940w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/10\/3-inconvenient-getpreview-handler.png 1118w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Preview of thumbnail in the site the page is stored<\/figcaption><\/figure>\n\n\n\n<p>Approach from another site eg the root results in a 404 Not found:<br><a href=\"https:\/\/tenant.sharepoint.com\/_layouts\/15\/getpreview.ashx?path=https:\/\/tenant.sharepoint.com\/sites\/sitename\/SitePages\/Belgi\u00eb.aspx\">https:\/\/tenant.sharepoint.com\/_layouts\/15\/getpreview.ashx?path=https:\/\/tenant.sharepoint.com\/sites\/sitename\/SitePages\/Belgi\u00eb.aspx<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"988\" height=\"277\" src=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/10\/4-inconvenient-getpreview-handler.png\" alt=\"\" class=\"wp-image-2794\" srcset=\"https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/10\/4-inconvenient-getpreview-handler.png 988w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/10\/4-inconvenient-getpreview-handler-300x84.png 300w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/10\/4-inconvenient-getpreview-handler-768x215.png 768w, https:\/\/www.itidea.nl\/wp-content\/uploads\/2019\/10\/4-inconvenient-getpreview-handler-940x264.png 940w\" sizes=\"auto, (max-width: 988px) 100vw, 988px\" \/><figcaption>No preview available from another site<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>To\nbe sure the getpreview handler can generate the thumbnails of a file at all\ntimes use the guid parameters instead of the path parameter.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Thumbnails for pages in SharePoint Online are generated using the getpreview handler. Using this handler predefined image formats can be used using the &#8216;resolution&#8217; URL parameter. When this parameter isn&#8217;t specified resolution 0 is used: fixed width of 300px. Besides &#8230; <a class=\"more-link\" href=\"https:\/\/www.itidea.nl\/index.php\/inconvenient-getpreview-ashx\/\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39,41],"tags":[37,46],"class_list":["post-2792","post","type-post","status-publish","format-standard","hentry","category-office-365","category-sharepoint","tag-office365","tag-sharepoint"],"_links":{"self":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/2792","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/comments?post=2792"}],"version-history":[{"count":3,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/2792\/revisions"}],"predecessor-version":[{"id":2799,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/posts\/2792\/revisions\/2799"}],"wp:attachment":[{"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/media?parent=2792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/categories?post=2792"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itidea.nl\/index.php\/wp-json\/wp\/v2\/tags?post=2792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}