Shopify keeps renaming all of my uploaded product photos and alt text. HELP!

Someone please help. Whenever I upload product images, I name the files beforehand for SEO, then i upload them, and edit the alt text for each one individually. Whenever i log back on the next day, all the image file names change and all the alt text reverts to the alt text listed below. I havent used that alt text in months, when i first started shopify, but every image i add keeps changing what i write and the alt text and image name changes to this.

Is there something in my shopify code that is causing all my image file names and alt text to change? This is very seriously affecting my SEO. Please help!

My site:

https://woodlandpulse.com/

1 Like

This is happening to me too. I would really like to know what is happening. I never had a problem with this before.

the same thing is happening to us as well unfortunately, yesterday i contacted shopify support but i wasnt able to get a proper answer to this… we are uploading hundreds of product images at once because we have many variants to a product, and this is a pain in the … for real, until now it wasn’t doing this, and no way that we are going to edit the url handles one by one… hopefully someone knows the solution to this

Hi! I figured it out. Are you using the application tinyIMG by chance? I was and they automatically change all of your alt text. I had to go in and turn that setting off.

1 Like

I do any and all optimizing/compressing and name my file before I drop and drag it to Shopify and they haven’t changed anything since I’ve been doing that.

The only way I could get the file card that says “Drag and Drop” your file here, the only way I can get it to open is if I am changing the image on my Logo. So I click customize on one of my duplicate themes and go through the motions like I’m changing my logo and when the card pops out to drag or drop I have my Downloads folder and my shopify images page both open halfway on the screen and I drag one picture at a time. Then i just close out the duplicate theme and the photo is in my files and you can use it wherever , your file stays whatever you named it.

I am very new to web design so if anyone knows something more simple, please post it. But my inventory is very small so it isn’t much of a hassle for me. With big inventory it would stink lol

Hey there,

Images are renamed due to the size which you’re trying to upload, your image is 2048x1519px which is why it’s being renamed after being optimized by Shopify. Try to upload a lower resolution image with less than 250kb in size, this way, images won’t be renamed as it’s already optimized before upload.

1 Like

My images are 1600x1600 with a size between 55 and 90 kb. Shopify renames them anyway and creates a double file..

It is possible to assign own custom filenames during the upload, for example, using Python.

  1. Go to your Shopify Store under APPS and create a DEVELOPER APP with full access. Then, make a note of the API credentials.
  2. In the Python code below, input your access credentials and your store name without “myshopify.com.” For example, if your store URL is “example.myshopify.com,” use only “example.”. Save it as e.g. image_upload.py.
  3. You need to have a directory structure as shown in the example below. Note that your folders on your local machine should consist of the Shopify Product ID and the product name. This structure allows the script to extract the Product ID to correctly associate the images during upload. (You can use a Python script to download everything from Shopify and create folder names correctly with ID and product name, or you can do it manually if you have only a few products). Prefix the filenames with “01-”, “02-”, or however you prefer to ensure the upload sequence aligns with how a user will see the products later.
Example:

c:\my-shopify-store\image_upload.py
|-- your_image_path
|   |-- 9327095906607-Productname-a
|   |   |-- 01-filename_xy.jpg
|   |   |-- 02-filename_yz.jpg
|   |   |-- 03-filename_ab.jpg
|   |
|   |-- 9327095945689-Productname-b
|       |-- 01-filename_xy.jpg
|       |-- 02-filename_yz.jpg
|       |-- 03-filename_ab.jpg

Python-Script:

import os
import requests
import base64
import re
import time

# API and Shop Information
API_KEY = 'YOUR_API_KEY_HERE'
PASSWORD = 'YOUR_PASSWORD_HERE'
SHOP_NAME = 'YOUR_SHOP_NAME_HERE'

# Directory for Images
backup_dir = 'your_image_path'

def upload_image(product_id, product_name, image_path):
    url = f'https://{SHOP_NAME}.myshopify.com/admin/api/2023-10/products/{product_id}/images.json'
    headers = {'Content-Type': 'application/json'}
    filename = os.path.basename(image_path)

    with open(image_path, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read()).decode('utf-8')

    data = {
        'image': {
            'attachment': encoded_string,
            'alt': product_name,
            'filename': filename
        }
    }

    response = requests.post(url, auth=(API_KEY, PASSWORD), headers=headers, json=data)
    if 200 <= response.status_code < 300:
        print(f'Image uploaded successfully: {image_path}')
    else:
        print(f'Error uploading image: {image_path}\n{response.text}')

def upload_all_product_images():
    for root, dirs, files in os.walk(backup_dir):
        for dir_name in dirs:
            match = re.match(r'(\d+)-(.+)', dir_name)
            if match:
                product_id = match.group(1)
                product_name = match.group(2)
                product_dir = os.path.join(root, dir_name)
                image_files = sorted(os.listdir(product_dir))
                for image_name in image_files:
                    if image_name.lower().endswith(('.jpg', '.jpeg', '.png', '.gif', '.bmp')):
                        image_path = os.path.join(product_dir, image_name)
                        if os.path.isfile(image_path):
                            upload_image(product_id, product_name, image_path)
                            time.sleep(1)

if __name__ == '__main__':
    upload_all_product_images()
    print('Upload of images for all products completed.')

Tested with python 3.11. hope that helps, best,

Stefan

1 Like