Download image from news list, getpreview.ashx

Iron Contributor

We need to download content and images from our Sharepoint news items to put these into our kiosk solution. Getting the text from the items is simple however for the images we cannot find where they are stored. All images for a news item (and other pages) are consumed and stored somewhere and then rendered in sharepoint via layouts/15/getpreview.ashx? which has a webguid, siteguid and file guid passed as parameters.


my question is twofold, where are the images saved - in a hidden list somewhere? - we cant find one.

is is possible to download an image via some mechanism?

3 Replies

not an ideal solution, but its the best we could come up with... 


$userName = "username"
$password = "pwd"
$pageUrl = ""

$image = "c:\junk\someimage.jpg"

#create secure password
$sPassword = $password | ConvertTo-SecureString -AsPlainText -Force

$webClient = New-Object System.Net.WebClient
$webClient.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $sPassword)
$webClient.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
$webClient.DownloadFile($pageUrl, $limage)

@David Bargna 


News posts create a new folder in your Site Assets library - which contain the images associated with that news post.


Question 1. Go to Site Assets > Site Pages > Folder with your news post's title. There you'll find the images associated with that news post.


Question 2. You can use PowerShell to grab that item (the image) and download the filestream then write it to your disk. You can also download through the UI.

best response confirmed by David Bargna (Iron Contributor)

@Thomas Berman 


thanks, that's we assumed, however we have 70 news posts, and only 2 site assets folders, some images are stored in the 'images' folder.


the solution we came up works well, as we can specify the image size to download and send to our kiosk system via powershell without having to worry about the original location of the image.


just for completion, here is the script to download images, metadata and stick them into a json which are kiosk consumes.

$cred = New-Object System.Management.Automation.PsCredential ....
Connect-PnPOnline '' -Credentials $cred
#kiok json
    "public images"=@{
$webClient = New-Object System.Net.WebClient
$webClient.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($cred.UserName,$cred.password )
$webClient.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
#get items
Foreach ($item in $newslist)
  # desctription.
  if ($item.FieldValues.Description -ne $null){
  #http content.
  $simple_json.visuals.'public images'.id="$rootpath$($item.fieldvalues.Title).jpg"
  $webClient.DownloadFile($item.FieldValues.BannerImageUrl.Url, "$rootpath$($item.fieldvalues.Title).jpg")
$stuff | ConvertTo-Json |Out-File kiosk.json  -Encoding utf8