There is no way of recalling Product Images depending on the Alt tag; the ShopifyAPI does not allow for it.
Saying that though, here is a trade secret...
Just tag on the value of the Alt tag to the filename of the image.
images = params[:images] || nil
if images
images.each do |image|
a = ShopifyAPI::Image.new
a.prefix_options = {:product_id => params[:product_id]}
a.metafields = [{:key => 'alt', :value => 'Cake', :value_type => "string", :namespace => "tags"}]
a.attachment = Base64.encode64(image.read)
a.filename = 'Cake_'+image.original_filename
a.save
end
else
.
.
.
That way, you can filter the Product Images via the string value 'Cake_' on the ':src' attribute.
@product = ShopifyAPI::Product.find(params[:id])
@product.images.each do |image|
if image.attributes[:src].include?('Cake_')
.
.
.
end
end
Hope that helps!