Adding a link to my image

Hi ,
I have my streamlit app on a GitHub depository
On mt sidebar I added an image of the LinkedIn logo using this code

st.sidebar.image("LinkedIn.png")

Here’s the result

Capture d’écran 2023-10-19 à 15.21.40

I want to make this image clickable so it can redirect to my LinkedIn page.

Can someone please help me ?

Thanks in advance

2 Likes

Hi @AliaBoudehane,

Thanks for posting!

You can use st.markdown to embed the image with a hyperlink to LinkedIn.

Here’s the code you can try (make sure to add your username in the LinkedIn URL:

st.sidebar.markdown(
    """<a href="https://www.linkedin.com/in/your-profile-username/">
    <img src="data:image/png;base64,{}" width="25">
    </a>""".format(
        base64.b64encode(open("LinkedIn.png", "rb").read()).decode()
    ),
    unsafe_allow_html=True,
)

Let me know if this works.

3 Likes

Hello @tonykip ,

Thanks for your answer.
It perfectly worked !

Have a nice day.

1 Like

Hi @AliaBoudehane,

Glad it worked! Happy Streamlit-ing! :balloon:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.