ZW Amazon Image Fetcher
WordPress plugin to fetch Amazon product images via the Creators API
by Matt Zimmerman · github.com/mezimm/zw-amazon-image-fetcher · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/mezimm/zw-amazon-image-fetcher/archive/refs/heads/main.zipLightweight shortcode plugin to fetch Amazon product images via Creators API with 24-hour transient caching.
Description
ZW Amazon Image Fetcher provides a simple shortcode to retrieve Amazon product images directly from the Amazon Creators API. It supports all Amazon marketplaces and caches image URLs for 24 hours (per Amazon TOS requirements).
Features:
- Simple shortcode:
[zw asin="B08N5WRWNW"] - Multi-marketplace support (US, UK, DE, FR, etc.)
- 24-hour transient caching (lazy refresh - only updates when page is visited)
- Batched API requests (up to 10 ASINs per request)
- Automatic retry queue with exponential backoff
- Secure - input sanitization and output escaping
- Simple admin settings page
- Supports both GUI configuration and wp-config.php (recommended for multi-site)
Installation
- Upload the
zw-amazon-image-fetcherfolder to/wp-content/plugins/ - Activate the plugin through the 'Plugins' menu in WordPress
- Go to Settings > ZW Amazon Images to configure your API credentials
Configuration
Option 1: Settings Page (Easy) Go to Settings > ZW Amazon Images and enter your credentials.
Option 2: wp-config.php (Recommended for Security/Multi-Site)
Add these constants to your wp-config.php file:
define( 'ZW_CREATORS_CREDENTIAL_ID', 'abc12def3ghijk4lmnop5qrstu' ); define( 'ZW_CREATORS_CREDENTIAL_SECRET', '1abc2def3ghij4klmno5pqrst6uvwxy7zabcd8efghi9jklmn0opqrs' ); define( 'ZW_AWS_PARTNER_TAG', 'yoursite-20' ); define( 'ZW_AWS_DEFAULT_MARKETPLACE', 'amazon.com' );
Note: wp-config.php settings take priority over the settings page. This is the recommended approach if you manage multiple sites, as database-stored credentials can be exposed if your site is compromised.
Usage
Basic usage (uses default marketplace):
[zw asin="B08N5WRWNW"]
With specific marketplace:
[zw asin="B08N5WRWNW" marketplace="amazon.co.uk"]
[zw asin="B09V3KXJPB" marketplace="amazon.de"]
Supported Marketplaces:
- amazon.com (US)
- amazon.ca (Canada)
- amazon.com.mx (Mexico)
- amazon.com.br (Brazil)
- amazon.co.uk (UK)
- amazon.de (Germany)
- amazon.fr (France)
- amazon.es (Spain)
- amazon.it (Italy)
- amazon.nl (Netherlands)
- amazon.pl (Poland)
- amazon.se (Sweden)
- amazon.in (India)
- amazon.sa (Saudi Arabia)
- amazon.com.au (Australia)
- amazon.co.jp (Japan)
- amazon.sg (Singapore)
Frequently Asked Questions
Where do I get API credentials?
You need an Amazon Associates account and Creators API access. Go to https://affiliate-program.amazon.com/creatorsapi to generate your Credential ID and Credential Secret.
Why is the shortcode returning empty?
Check your PHP error log. Common issues:
- Invalid or missing API credentials
- Invalid ASIN (must be exactly 10 alphanumeric characters)
- Product doesn't exist in the specified marketplace
- API throttling (Creators API has rate limits)
Can I use different partner tags per marketplace?
This plugin uses a single partner tag for API authentication. If you need different affiliate tags for tracking, handle that separately in your link generation.
What changed in version 4.0.0?
Version 4.0.0 migrates from Amazon PA-API 5.0 to the new Creators API. You will need to generate new credentials from your Associates dashboard. The old Access Key and Secret Key will no longer work - you need a Credential ID and Credential Secret instead.
Changelog
4.0.1
- Security: Log filename now includes hash of AUTH_KEY to prevent direct URL access
- Updated author information and plugin URIs
4.0.0
- BREAKING CHANGE: Migrated from PA-API 5.0 to Amazon Creators API
- New credentials required: Credential ID and Credential Secret (old AWS keys no longer work)
- Uses OAuth2 authentication instead of AWS Signature V4
- Updated admin settings page with new credential fields
- Automatic migration clears old caches on upgrade
2.6.0
- New: CSS auto-hide for table rows and list items when image fetch fails (no JavaScript required)
- New: Smart caching for "ItemNotAccessible" errors - caches for 30 days instead of 1 hour since retrying won't help
- Improved: Distinguishes between temporary API errors (1-hour cache) and permanent inaccessibility (30-day cache)
2.5.2
- Fixed: Submit button now always visible so 30-day cache option can be saved when credentials are in wp-config.php
2.5.1
- Fixed: Settings not saving when API credentials are defined in wp-config.php
2.5.0
- Added automatic retry on API failure (waits 1 second, then retries once)
- Added "Refresh Amazon Images" button in admin bar for posts/pages
- Button clears cache only for ASINs on the current page and reloads
2.4.0
- Added disclaimer notice at top of settings page
- 30-day backup cache is now optional (disabled by default)
- Added TOS warning for 30-day cache feature
- Cache Management section now shows current cache status
2.3.0
- Added two-tier caching: 24-hour primary + 30-day backup fallback
- If API fails, uses backup cache instead of showing nothing
- Added "Clear All Cache" button in settings
2.2.0
- Added negative caching - failed API calls cached for 1 hour to prevent hammering Amazon servers
2.1.0
- Added admin settings page (Settings > ZW Amazon Images)
- Settings can be configured via GUI or wp-config.php (wp-config takes priority)
- Added "Settings" link on plugins page
- Security recommendation displayed in admin
2.0.0
- Added multi-marketplace support
- Added input sanitization for ASIN
- Added output escaping for URLs
- Improved error logging
1.0.0
- Initial release