Automatically optimize the image resources in ArcGIS Hub Site pages

308
4
10-28-2021 08:45 AM
JoëlHempenius3
Occasional Contributor

I recently discoverd that removing an image from a ArcGIS Hub Site page only hides the image. It is still attached to the page as an resource. 

As my users frequently edit and update pages and the images on the pages, the page size started to grow and this became a problem when I had to clone a complete site and 500MB+ of data was copied.

I reached out to my local support and this was acknowledged as a bug, so hopefully, in the future, Esri will provide some means to manage the (image) resources of a Site page.

For now, I have a notebook script which makes it easy to get all the pages in a Site view all the image resources on a page and checks whether the image is used or not. In a final step, you can automatically backup and delete the unused images.
I'm sharing this here, because other users of ArcGIS Hub might be facing the same problem and maybe my script can help these users as well.

Have a look here for the script: https://arcgis.com/home/item.html?id=88695938832a4b748f8de78ad6658835

-Joël Hempenius.

Languages: JavaScript, Python and Dunglish
4 Replies
SamSimpson
New Contributor II

We have just started to use HUB at my work. I grew concerned after seeing a warning pop-up about an image already existing but I am unable to find the image anywhere in my organizations content.

I briefly looked at your notebook and I'm understanding it as you can only find previously uploaded images by turning them into content items, they are not searchable otherwise - is this correct?

Thank you for the script.

ESRI please fix this bug! You should be able to delete/overwrite images on the HUB, not just hide them.

0 Kudos
JoëlHempenius3
Occasional Contributor

Hi @SamSimpson 

If you want to use the default search functions in ArcGIS Online or Portal, no it is not possible to search for images or other resources attached to an item (Site page, storymap etc). So you are correct there. 

Using the ArcGIS API for Python, you can retrieve the existing resources on an item and list the file names and display them. This requires that you know in advance which Site page or storymap you want to find the image. 

That is what happens in my Python Notebook:

page = gis.content.get(pageid)
resources = page.resources.list()
for resource in resources:
#do stuff

You could extend my script to build this search functionality, should look like this on a high level:

  • Get all items in your ArcGIS Org
  • Loop through all items, retrieve all resources
  • Loop through the resources, try to match the resource name and yield it when a match is found

Wouldn't advice to do this, because there is no index, so doing something like above would take a lot of time if you have a lot of items you want to search for the image.

 

I'm working on a Angular, JSAPI4, Calcite fun project which gives me a nice UI UX for some admin tasks, might add a item resource browser to it as well. That browser should show all resources, offer update and delete functions and of course render the image when it's an image. Shouldn't be too much work 🙂

Will let it know here when I build that feature and when and where it's available. 

-Joël Hempenius.

Languages: JavaScript, Python and Dunglish
0 Kudos
SamSimpson
New Contributor II

Thank you, @JoëlHempenius3! Best of luck on the build out and please do let me know what comes of it.

 

 

0 Kudos
JoëlHempenius3
Occasional Contributor

@SamSimpson 
It still has a lot of rough edges and probably some bugs, but here is a very early version of my advanced mapping toolbox:
https://dev-maptools.gaiabuilder.com/

And using the I want to menu, you can view the resources of any item. 

Have a look and let me know what you think. 

-Joël Hempenius.

Languages: JavaScript, Python and Dunglish
0 Kudos