Updating a portal item's thumbnail with Python, with locally or externally stored images

446
4
04-20-2022 04:33 AM
LR2
by
New Contributor III

I'm running a script from a Notebook in Pro to update a couple of items. The description, terms, etc work, but I'm stuck on the thumbnail. Is it possible to use locally stored images, or images hosted on another server?

This is the code I use for the other parameters, e. g. the description:

from arcgis import GIS

gis = GIS("home")
desc = "this is a test"
test_item = gis.content.get('267cf15c2030453b94e6259822948fd6')
item_properties={"description":desc}
test_item.update(item_properties)

Parameter "thumbnailurl" won't work with either local nor hosted images.

Reference: https://developers.arcgis.com/rest/users-groups-and-items/common-parameters.htm

Tags (3)
4 Replies
jcarlson
MVP Esteemed Contributor

So what does it look like when you are specifically attempting to update the thumbnail? In particular, how are you formatting the filepath? I have done this with local files, and have had no issues with it.

- Josh Carlson
Kendall County GIS
0 Kudos
LR2
by
New Contributor III

Like this:

item_properties={"description":desc, "thumbnailurl":"D:\Temp\img\globe_200x133.png"}

or

item_properties={"description":desc, "thumbnailurl":"https://i.imgur.com/qRyvWoR.png"}

 

I also tried parameter "thumbnail", and file:\\\ for the local image.

0 Kudos
Clubdebambos
Occasional Contributor III

Hi @LR2 

You add the thumbnail directly in the update method. for URL below.

test_item.update(thumbnail="https://i.imgur.com/qRyvWoR.png")

 

This will also work for filepaths, just remember the r in front of the string if using backslashes.

test_item.update(thumbnail=r"D:\Temp\img\globe_200x133.png")

 

~ Mapping my way to retirement
Levon_H
New Contributor II

Easy enough.  Works like a charm. Thanks!

0 Kudos