title: Scrapy Custom ImagePipeline Settings.py
body: <p>I have written my own ImagePipeline for my scrapy project.  From my Googling I am getting different information about how to set the pipline in settings.py.</p>
  
  <p>Let's say the pipeline is MyImagesPipeline and it exists in pipelines.py which contains:</p>
  
  <pre><code>class MyImagesPipeline(ImagesPipeline):
      def get_media_requests(self, item, info):
          for image_url in item['image_urls']:
              yield scrapy.Request(image_url)
  
      def item_completed(self, results, item, info):
  
          some processing...
          return item
  </code></pre>
  
  <p>in my settings.py:</p>
  
  <pre><code>ITEM_PIPELINES = {
      'scrapy.contrib.pipeline.images.ImagesPipeline': 1,
      'myproject.pipelines.MyImagesPipeline': 100,
     }
  </code></pre>
  
  <p>I have two pipelines in there because if I put in MyImagesPipeline alone item_completed gets called but without any images and I get a KeyError because the field 'images' is not there. However, with both middlewares in the settings I am getting multiple copies of the same image.</p>
  
  <p>Can someone please enlighten me on this?</p>
  
  <p>EDIT:</p>
  
  <p>The spider code is quite long because I am doing a lot of information processing in it but here are what I think might be the relevant parts (callback of parse):</p>
  
  <pre><code>def parse_data(self, response):
      img_urls = response.css('.product-image').xpath('.//img/@src').extract()
      img_url = img_urls[0]
      item['image_urls'] = [img_url,]
      yield item
  </code></pre>