Icon Type is Incorrectly Reported in manifest.json for Android

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:

4 Likes

Where is the manifest.json file used?

I think the android pretend web page is app feature uses this: https://developers.google.com/web/updates/2014/11/Support-for-installable-web-apps-with-webapp-manifest-in-chrome-38-for-Android

3 Likes

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.

2 Likes

Is this still an issue @featheredtoast?

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

3 Likes

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

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.

2 Likes

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:

https://github.com/discourse/discourse/commit/41ffafb65e4fc9a305e35b900d689f15cf0f3890

2 Likes

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.

3 Likes

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:

https://github.com/discourse/discourse/commit/04c7dbafa32991836a688e979e03b117e8ec8c19

3 Likes

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