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

def get_base64_of_bin_file(bin_file):
with open(bin_file, ‘rb’) as f:
data =
return base64.b64encode(data).decode()

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’, ‘’)
st.markdown(gif_html, unsafe_allow_html=True)