Icon Type is Incorrectly Reported in manifest.json for Android

(Ricardo N Feliciano) #1

In every Discourse site’s manifest.json file, a list of icons are shown. For each icon, a “type” is provided which looks to be the icon’s mime type. Problem is, regardless of which format the icon actually is (ico, jpeg, svg), the provided type is image/png.

Examples of Discourse sites with this problem:

(Jeff Atwood) #2

Where is the manifest.json file used?

(Sam Saffron) #3

I think the android pretend web page is app feature uses this: Installable Web Apps with the Web App Manifest in Chrome for Android  |  Web  |  Google Developers

(Ricardo N Feliciano) #4

Yup - the file mainly supports the Android “Save to Homescreen” feature which then opens up that site as an app (Chrome WebView).

Other software projects nowadays rely on that file as well for their own webapp needs. Such as when Ubuntu had Unity Webapps which allows a saved site to have their own icon in the Unity Launcher.

I wouldn’t be surprised if more sites use that file, though I can’t personally list anymore.

(Jeff Atwood) #5

Is this still an issue @featheredtoast?

(Jeff Wong) #6

I haven’t made any changes to the manifest during my time in serviceworker land, but I’ll check it out

(Ricardo N Feliciano) #8

This is still an issue as of Discourse 2.0.0.beta7. Can be seen here: https://forums.theanimenetwork.com/manifest.json

(Rafael dos Santos Silva) #9

The easiest fix is only using large icon url there. However most Discourse instances doesn’t fill this field and will lose the add to homescreen banner then.

(Jeff Wong) #10

It’s not perfect without downloading and inspecting the file itself, but I’ve added a “best effort” educated guess at figuring out the mime type from the filename alone which should resolve the common cases:

(Rafael dos Santos Silva) #11

Is there a way to check if the file exists in the uploads table?

I believe in most cases it will be there and we can get extension and size from there.

(Jeff Wong) #12

Oh good point, let me see what I can do there.

Utilizing the mini-mime lib properly now.

I also attempts to use thesize dimensions if they exist in an upload as well. :cherries:

(Jeff Wong) #13

This topic was automatically closed after 4 days. New replies are no longer allowed.