$image) { $url = $image['SmallImage']['URL']; // URL of the form: 'http://ecx.images-amazon.com/images/I/518FFDVWNQL._SL160_.jpg $data[] = preg_replace('!(http://(?:[^/]*/)+(?:[^.]*)).*$!', '\1._SL'.$keyword.'_.jpg', $url); } } else if (!empty($images['URL'])){ $url = $images['URL']; // URL of the form: 'http://ecx.images-amazon.com/images/I/518FFDVWNQL._SL160_.jpg $data[] = preg_replace('!(http://(?:[^/]*/)+(?:[^.]*)).*$!', '\1._SL'.$keyword.'_.jpg', $url); } return array_values(array_unique($data)); } /* * Filter to change the thumb & image keyword and attach a filter to it to munge the URL */ function alx_images_keywords ($keywords) { $keywords['thumb']['Callback'] = 'alx_images_process_images'; $keywords['thumb']['Position'] = array(array('ImageSets'), array('SmallImage')); $keywords['image']['Callback'] = 'alx_images_process_images'; $keywords['image']['Position'] = array(array('ImageSets'), array('SmallImage')); $keywords['images'] = array( 'Description' => __('Images Array', 'amazon-link'), 'Live' => 1, 'Link' => 1, 'Default' => '' ); $keywords['thumbs'] = array( 'Description' => __('Thumbs Array', 'amazon-link'), 'Live' => 1, 'Link' => 1, 'Default' => '' ); $keywords['image_size'] = array( 'Description' => __('Size of Images', 'amazon-link')); $keywords['thumb_size'] = array( 'Description' => __('Size of Thumbnails', 'amazon-link')); add_filter('amazon_link_template_process_thumbs', 'alx_images_display_images',11,6); add_filter('amazon_link_template_process_images', 'alx_images_display_images',11,6); return $keywords; } /* * Add the Image options to the Amazon Link Settings Page */ function alx_images_option_list ($options_list) { $options_list['image_size'] = array ( 'Name' => __('Preferred Image Size', 'amazon-link'), 'Description' => __('Retrieve the URL to an Image with the width or height (the longest) of this size rather than the default \'Large\' Image.', 'amazon-link'), 'Type' => 'text', 'Default' => '800', 'Class' => 'al_border'); $options_list['thumb_size'] = array ( 'Name' => __('Preferred Thumb Size', 'amazon-link'), 'Description' => __('Retrieve the URL to a Thumbnail with the width or height (the longest) of this size rather than the default \'Small\' Image.', 'amazon-link'), 'Type' => 'text', 'Default' => '100', 'Class' => 'al_border'); $options_list['max_images'] = array ( 'Name' => __('Image Array Limit', 'amazon-link'), 'Description' => __('Limit the number of images/thumbnails returned by the %IMAGES% or %THUMBS% keywords.', 'amazon-link'), 'Type' => 'text', 'Default' => '5', 'Class' => 'al_border'); $options_list['images_template'] = array ( 'Name' => __('Image Array Template', 'amazon-link'), 'Description' => __('Template to use when processing %IMAGES% keyword.', 'amazon-link'), 'Type' => 'textbox', 'Default' => '