How to get and use a value of image button

I found this code to use images as button.
Using this code, when a user press the button, another tap is opened.

but I wonder how I can get the value(variable) of the pressed button.

For example, when the user pressed the โ€˜lionโ€™ image button, the string โ€œlionโ€ or image name is saved in the variable โ€˜imgโ€™.

Because I want to use the variable โ€˜imgโ€™ to code the sidebar function in another tap.

** So, how can get the value of the pressed image button and then use the value to code for changing the sidebar in another tap? **


import streamlit as st
import os
import base64

@st.cache(allow_output_mutation=True)
def get_base64_of_bin_file(bin_file):
with open(bin_file, โ€˜rbโ€™) as f:
data = f.read()
return base64.b64encode(data).decode()

@st.cache(allow_output_mutation=True)
def get_img_with_href(local_img_path, target_url):
img_format = os.path.splitext(local_img_path)[-1].replace(โ€™.โ€™, โ€˜โ€™)
bin_str = get_base64_of_bin_file(local_img_path)
html_code = fโ€™โ€™โ€™


โ€˜โ€™โ€™
return html_code

gif_html = get_img_with_href(โ€˜tenor.gifโ€™, โ€˜https://docs.streamlit.ioโ€™)
st.markdown(gif_html, unsafe_allow_html=True)