Skip to content

Commit

Permalink
separated front and back thumbnail urls
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminleesmith committed Mar 2, 2011
1 parent 1fe3e40 commit 9315834
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/cafepress_api.rb
Expand Up @@ -67,9 +67,15 @@ def self.get_store_products(cafepress_store_id, app_key = ENV['cp_app_key'])

# Create a product thumbnail hash where the key is the color of the
# thumbnail and the value is the url to the image
thumbnail_urls_100x100 = {}
front_thumbnail_urls_100x100 = back_thumbnail_urls_100x100 = {}
product.get_elements("productImage[@imageSize='100']").each do |product_image|
thumbnail_urls_100x100[product_image.attributes['colorId']] = product_image.attributes['productUrl']
if product_image.attributes['productUrl'].includes('_Front_')
front_thumbnail_urls_100x100[product_image.attributes['colorId']] = product_image.attributes['productUrl']
elsif product_image.attributes['productUrl'].includes('_Back_')
back_thumbnail_urls_100x100[product_image.attributes['colorId']] = product_image.attributes['productUrl']
else
front_thumbnail_urls_100x100[product_image.attributes['colorId']] = product_image.attributes['productUrl']
end
end

products << {
Expand All @@ -80,7 +86,8 @@ def self.get_store_products(cafepress_store_id, app_key = ENV['cp_app_key'])
:cafepress_design_id => product.get_elements("mediaConfiguration[@perspectives='Front']").first.attributes['designId'],
:cafepress_back_design_id => cafepress_back_design_id,
:gender => gender, # See comment above
:thumbnail_urls_100x100 => thumbnail_urls_100x100
:front_thumbnail_urls_100x100 => front_thumbnail_urls_100x100,
:back_thumbnail_urls_100x100 => back_thumbnail_urls_100x100
}
end
products
Expand Down

0 comments on commit 9315834

Please sign in to comment.