This script automatically adds alt tags to all the images (including featured images) on your blog using SceneXplain.
Platform | Post images | Page images | Media images | Product images | Notes |
---|---|---|---|---|---|
Ghost | ✅ | Pending | N/A | N/A | Tested, works decently |
WordPress | ✅ | ✅ | ✅ | N/A | Converts post content to HTML |
WooCommerce | Use WordPress handler | Use WordPress handler | Use Wordpress handler | ✅ | Experimental |
Shopify | ✅ | ✅ | Experimental |
When you run the script or Docker image it will:
- Download each content item from whatever platform you're using
- Check each image to see if it has alt text:
- If yes, skip that image
- If no, create an alt text using SceneXplain and write that to the post data
- Check if the content has new alt texts:
- If yes, update the content
- If no, skip update
Environment variables let you safely define your credentials and settings. No matter which platform you use, you will need:
Environment variable name | Required? | Default value | Notes |
---|---|---|---|
PLATFORM |
No | ghost |
ghost , wordpress , woocommerce or shopify |
SCENEX_API_KEY |
Yes | None | Generate here |
Then, depending on your platform, you will need to set additional variables to define your URL and credientials:
Environment variable name | Required? | Default value | Notes |
---|---|---|---|
GHOST_BLOG_URL |
Yes | None | Must include "http(s)" prefix |
GHOST_API_KEY |
Yes | None |
Environment variable name | Required? | Default value | Notes |
---|---|---|---|
WORDPRESS_URL |
Yes | None | Must include "http(s)" prefix |
WORDPRESS_USERNAME |
Yes | None | |
WORDPRESS_PASSWORD |
Yes | None |
Environment variable name | Required? | Default value | Notes |
---|---|---|---|
WOOCOMMERCE_URL |
Yes | None | Must include "http(s)" prefix |
WOOCOMMERCE_KEY |
Yes | None | Your WooCommerce consumer key |
WOOCOMMERCE_SECRET |
Yes | None | Your WooCommerce consumer secret |
Environment variable name | Required? | Default value | Notes |
---|---|---|---|
SHOPIFY_SHOP_NAME |
Yes | None | |
SHOPIFY_ACCESS_TOKEN |
Yes | None | Your Shopify Admin API access token |
Fill in the environment variables (denoted by angle brackets) and run the code. For each line that begins with -e
you'll need to specify each of your environment variables from your platform above. For example, if you use Ghost, you would specify:
docker run -d --name alt-texter \
-e SCENEX_API_KEY=<scenex-api-key> \
-e PLATFORM=ghost \
-e GHOST_API_KEY=<ghost-api-key> \
-e GHOST_BLOG_URL="<ghost-blog-url>" \
jinaai/alt-texter:0.1
- Clone this repo then enter its directory.
- Run
pip install -r requirements.txt
to install requirements. - Fill in the environment variables (denoted by angle brackets) and run the code.
env GHOST_API_KEY=<ghost-api-key> \
SCENEX_API_KEY=<scenex-api-key> \
GHOST_BLOG_URL="<ghost-blog-url>" \
python app.py
WooCommerce is a WordPress plugin, so you should use the WordPress handler to update the posts and pages on your site.
I have no expertise in that area. If someone wants to lend a hand, drop an issue and let's chat!