Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep support for ICO formats by defaulting to PNG if necessary #4340

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added e2e/scripts/assets/favicon.ico
Binary file not shown.
5 changes: 5 additions & 0 deletions e2e/scripts/st_set_page_config_icon.py
@@ -0,0 +1,5 @@
import streamlit as st

st.set_page_config(
page_icon="e2e/scripts/assets/favicon.ico",
)
31 changes: 31 additions & 0 deletions e2e/specs/st_set_page_config_icon.spec.js
@@ -0,0 +1,31 @@
/**
* @license
* Copyright 2018-2022 Streamlit Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

describe("st.set_page_config with ICO", () => {
before(() => {
cy.loadApp("http://localhost:3000/");
});

it("sets the page favicon with ico file", () => {
cy.get("link[rel='shortcut icon']")
.invoke("attr", "href")
.should(
"eq",
"http://localhost:8501/media/92018b2805266c4cb9a98e90c849ce5b5e7ba6d1af423bd7b7c345da.png"
);
});
});
2 changes: 2 additions & 0 deletions lib/streamlit/elements/image.py
Expand Up @@ -207,6 +207,8 @@ def _normalize_to_bytes(data, width, output_format):
if output_format.lower() == "auto":
ext = imghdr.what(None, data)
mimetype = mimetypes.guess_type("image.%s" % ext)[0]
if mimetype is None:
mimetype = "image/" + format.lower()
else:
mimetype = "image/" + format.lower()

Expand Down