Skip to content

Instantly share code, notes, and snippets.

@kevindaus
Created October 24, 2019 00:54
Show Gist options
  • Save kevindaus/eb2f14dca95631f72634215e9ae35b33 to your computer and use it in GitHub Desktop.
Save kevindaus/eb2f14dca95631f72634215e9ae35b33 to your computer and use it in GitHub Desktop.
#!/bin/sh
PRODUCT_ID=$1
if [ -z "${PRODUCT_ID}" ]; then
echo "Requires a product ID"
echo
echo "run \"./script.sh <id>\""
fi
IMAGE_GALLERY=$(wp post meta get "${PRODUCT_ID}" _product_image_gallery)
THUMBNAIL_ID=$(wp post meta get "${PRODUCT_ID}" _thumbnail_id)
RAW_IDS="${IMAGE_GALLERY},${THUMBNAIL_ID}"
IDS=`echo "${RAW_IDS}" | tr ',' ' '`
wp media regenerate "${IDS}"
exit
@kevindaus
Copy link
Author

kevindaus commented Oct 24, 2019

Usage
./script.sh <product_id>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment