I am trying to get alt text of featured image using rest api and python.
Here is my code:
media = {
"file": open(f"images/{filename}", "rb"),
"caption": "caption",
"description": "description",
"alt_text": "Custom Alt Text",
}
upload_image = requests.post(url + "/media", headers=headers, files=media)
Everything works fine instead of alt text. It keeps blank.
Anyone, please help me if I did anything wrong or missed something?
Thanks
As I saw your code, I think you want to set
alt_textfor the image.If you want to upload an image by using
WordPress REST APIand set analt_textfor it, you can use the following function: