I have a popup configured to show an image 100px by 100px. The images aren't all square so I'm trying to get the image to be cropped using the 'object-fit' property of the <img> tag. The relevant snippet of ARCADE code is included below:
if ($feature.thumbnailimageurl != null){
image = "<img src='" + $feature.thumbnailimageurl + "' alt='Photograph of " + studyspacename + "' width='100px' height='100px' style='float:right; padding-left:5px; overflow:clip; object-fit:cover;'/>"
}
However, using the Dev Tools to inspect the source of the map it seems that Map Viewer is stripping off the 'object-fit' property as the <img> tag in the popup is rendered as follows:
<img src="https://edinageo.maps.arcgis.com/sharing/rest/content/items/7e43551055214d9abb9623560c7bea90/data" alt="Photograph of Law School Library" width="100px" height="100px" style="float:right; padding-left:5px; overflow:clip;">
Note that the 'object-fit' property is not there.
Consequently any of the images that are not roughly square look horrible as they get squished to 100px by 100px.
Is this a known limitation in Map Viewer (annoyingly using the exact same code in Experience Builder to display the image in a Card Widget works fine)? Is there a documented list of supported properties anywhere? Is there a workaround? Any help would be greatly appreciated as it's not feasible to resize all my images to be square as they're used in other live services where the aspect ratio doesn't matter.
Original image:
How it displays in Map Viewer: [note the image is squashed horizontally]
How it displays in a Card Widget in Experience Builder: [note the image is not squashed at all and is cropped retaining the central section (this is what I'm trying to replicate in Map Viewer)]
Solved! Go to Solution.
@MappyIan, you may want to check out Supported HTML—ArcGIS Online Help | Documentation. I haven't built anything as fancy as your pop-ups, so maybe someone with more experience can chime in, but it doesn't look like that's a supported attribute of the img tag.
In Experience Builder, you can set images to "fit" or "fill," and I'm guessing that has something to do with why you're seeing a difference.
@MappyIan, you may want to check out Supported HTML—ArcGIS Online Help | Documentation. I haven't built anything as fancy as your pop-ups, so maybe someone with more experience can chime in, but it doesn't look like that's a supported attribute of the img tag.
In Experience Builder, you can set images to "fit" or "fill," and I'm guessing that has something to do with why you're seeing a difference.
Hey @NicoleJohnson, thanks for the reply. The link to the 'Supported HTML' page is super helpful. The thing that gets me is that the 'object-fit' property is not listed in the CSS Properties section of the page, yet it's clearly supported in Experience Builder as it behaves as desired. Maybe I should just be grateful that it works in ExB if it's not supported and stop complaining!
I've submitted this as an 'idea'. If you think this would be useful, please give this idea some kudos: