title: Magento: Load/Use Image Base URL instead of Cached URL
body: <p><strong>Does anybody know how to get Magento to use the actual base URL of images instead of the cached ones?</strong></p>
  
  <p><strong>Using Magento Community V 1.6.2.0</strong></p>
  
  <p>If I look at the URL of a product image you get something like this…</p>
  
  <p>/media/catalog/product/cache/1/image/390x/5e06319eda06f020e43594a9c230972d/1/1/1101012001-J-1Front-Man/.jpg</p>
  
  <p>I need for it to be more like:</p>
  
  <p>/media/catalog/product/1101012001-J-1Front-Man/.jpg</p>
  
  <p>Reason is that I'm using the M2EPro extension which allows you to sync products for sale/sold in Magento with eBay/Amazon. <strong>Problem is that eBay does not allow image URLs that are longer that 150 characters.</strong> The MD5 hash and other mixed in variables (that I believe originate at /app/code/core/Mage/Catalog/Helper/Image.php) make the URL too long for it to be usable for many of my images.</p>
  
  <p>When M2EPro runs it pulls the cached image (because that is what Magento designates as the main image). I believe that I need to have only the absolute URL referenced and have not been able to put this all together yet.</p>
  
  <p><strong>I have seen lots and lots of similar questions that span years with no definite answer on this one. If I find the answer first I will post here, but any help is really, really appreciated!</strong></p>
  
  <p>Current code from Image.php file mentioned above:</p>
  
  <pre><code>$this-&gt;_baseFile = $baseFile;
  
          // build new filename (most important params)
          $path = array(
              Mage::getSingleton('catalog/product_media_config')-&gt;getBaseMediaPath(),
  
              Mage::app()-&gt;getStore()-&gt;getId(),
              $path[] = $this-&gt;getDestinationSubdir()
          );
          if((!empty($this-&gt;_width)) || (!empty($this-&gt;_height)))
              $path[] = "{$this-&gt;_width}x{$this-&gt;_height}";
  
          // add misk params as a hash
          $miscParams = array(
                  ($this-&gt;_keepAspectRatio  ? '' : 'non') . 'proportional',
                  ($this-&gt;_keepFrame        ? '' : 'no')  . 'frame',
                  ($this-&gt;_keepTransparency ? '' : 'no')  . 'transparency',
                  ($this-&gt;_constrainOnly ? 'do' : 'not')  . 'constrainonly',
                  $this-&gt;_rgbToString($this-&gt;_backgroundColor),
                  'angle' . $this-&gt;_angle,
                  'quality' . $this-&gt;_quality
          );
  
          // if has watermark add watermark params to hash
          if ($this-&gt;getWatermarkFile()) {
              $miscParams[] = $this-&gt;getWatermarkFile();
              $miscParams[] = $this-&gt;getWatermarkImageOpacity();
              $miscParams[] = $this-&gt;getWatermarkPosition();
              $miscParams[] = $this-&gt;getWatermarkWidth();
              $miscParams[] = $this-&gt;getWatermarkHeigth();
          }
  
          $path[] = md5(implode('_', $miscParams));
  
          // append prepared filename
          $this-&gt;_newFile = implode('/', $path) . $file; // the $file contains heading slash
  
          return $this;
      }
  
      public function getBaseFile()
      {
          return $this-&gt;_baseFile;
      }
  
      public function getNewFile()
      {
          return $this-&gt;_newFile;
      }
  
      /**
       * @return Mage_Catalog_Model_Product_Image
       */
      public function setImageProcessor($processor)
      {
          $this-&gt;_processor = $processor;
          return $this;
      }
  
      /**
       * @return Varien_Image
       */
      public function getImageProcessor()
      {
          if( !$this-&gt;_processor ) {
  //            var_dump($this-&gt;_checkMemory());
  //            if (!$this-&gt;_checkMemory()) {
  //                $this-&gt;_baseFile = null;
  //            }
              $this-&gt;_processor = new Varien_Image($this-&gt;getBaseFile());
          }
          $this-&gt;_processor-&gt;keepAspectRatio($this-&gt;_keepAspectRatio);
          $this-&gt;_processor-&gt;keepFrame($this-&gt;_keepFrame);
          $this-&gt;_processor-&gt;keepTransparency($this-&gt;_keepTransparency);
          $this-&gt;_processor-&gt;constrainOnly($this-&gt;_constrainOnly);
          $this-&gt;_processor-&gt;backgroundColor($this-&gt;_backgroundColor);
          $this-&gt;_processor-&gt;quality($this-&gt;_quality);
          return $this-&gt;_processor;
      }
  
      /**
       * @see Varien_Image_Adapter_Abstract
       * @return Mage_Catalog_Model_Product_Image
       */
      public function resize()
      {
          if (is_null($this-&gt;getWidth()) &amp;&amp; is_null($this-&gt;getHeight())) {
              return $this;
          }
          $this-&gt;getImageProcessor()-&gt;resize($this-&gt;_width, $this-&gt;_height);
          return $this;
      }
  
      /**
       * @return Mage_Catalog_Model_Product_Image
       */
      public function rotate($angle)
      {
          $angle = intval($angle);
          $this-&gt;getImageProcessor()-&gt;rotate($angle);
          return $this;
      }
  
      /**
       * Set angle for rotating
       *
       * This func actually affects only the cache filename.
       *
       * @param int $angle
       * @return Mage_Catalog_Model_Product_Image
       */
      public function setAngle($angle)
      {
          $this-&gt;_angle = $angle;
          return $this;
      }
  
      /**
       * Add watermark to image
       * size param in format 100x200
       *
       * @param string $file
       * @param string $position
       * @param string $size
       * @param int $width
       * @param int $heigth
       * @param int $imageOpacity
       * @return Mage_Catalog_Model_Product_Image
       */
      public function setWatermark($file, $position=null, $size=null, $width=null, $heigth=null, $imageOpacity=null)
      {
          if ($this-&gt;_isBaseFilePlaceholder)
          {
              return $this;
          }
  
          if ($file) {
              $this-&gt;setWatermarkFile($file);
          } else {
              return $this;
          }
  
          if ($position)
             $this-&gt;setWatermarkPosition($position);
          if ($size)
              $this-&gt;setWatermarkSize($size);
          if ($width)
              $this-&gt;setWatermarkWidth($width);
          if ($heigth)
              $this-&gt;setWatermarkHeigth($heigth);
          if ($imageOpacity)
              $this-&gt;setImageOpacity($imageOpacity);
  
          $filePath = $this-&gt;_getWatermarkFilePath();
  
          if($filePath) {
              $this-&gt;getImageProcessor()
                  -&gt;setWatermarkPosition( $this-&gt;getWatermarkPosition() )
                  -&gt;setWatermarkImageOpacity( $this-&gt;getWatermarkImageOpacity() )
                  -&gt;setWatermarkWidth( $this-&gt;getWatermarkWidth() )
                  -&gt;setWatermarkHeigth( $this-&gt;getWatermarkHeigth() )
                  -&gt;watermark($filePath);
          }
  
          return $this;
      }
  
      /**
       * @return Mage_Catalog_Model_Product_Image
       */
      public function saveFile()
      {
          $filename = $this-&gt;getNewFile();
          $this-&gt;getImageProcessor()-&gt;save($filename);
          Mage::helper('core/file_storage_database')-&gt;saveFile($filename);
          return $this;
      }
  
      /**
       * @return string
       */
      public function getUrl()
      {
          $baseDir = Mage::getBaseDir('media');
          $path = str_replace($baseDir . DS, "", $this-&gt;_newFile);
          return Mage::getBaseUrl('media') . str_replace(DS, '/', $path);
      }
  
      public function push()
      {
          $this-&gt;getImageProcessor()-&gt;display();
      }
  
      /**
       * @return Mage_Catalog_Model_Product_Image
       */
      public function setDestinationSubdir($dir)
      {
          $this-&gt;_destinationSubdir = $dir;
          return $this;
      }
  
      /**
       * @return string
       */
      public function getDestinationSubdir()
      {
          return $this-&gt;_destinationSubdir;
      }
  
      public function isCached()
      {
          return $this-&gt;_fileExists($this-&gt;_newFile);
      }
  
      /**
       * Set watermark file name
       *
       * @param string $file
       * @return Mage_Catalog_Model_Product_Image
       */
      public function setWatermarkFile($file)
      {
          $this-&gt;_watermarkFile = $file;
          return $this;
      }
  
      /**
       * Get watermark file name
       *
       * @return string
       */
      public function getWatermarkFile()
      {
          return $this-&gt;_watermarkFile;
      }
  
      /**
       * Get relative watermark file path
       * or false if file not found
       *
       * @return string | bool
       */
      protected function _getWatermarkFilePath()
      {
          $filePath = false;
  
          if (!$file = $this-&gt;getWatermarkFile())
          {
              return $filePath;
          }
  
          $baseDir = Mage::getSingleton('catalog/product_media_config')-&gt;getBaseMediaPath();
  
          if( $this-&gt;_fileExists($baseDir . '/watermark/stores/' . Mage::app()-&gt;getStore()-&gt;getId() . $file) ) {
              $filePath = $baseDir . '/watermark/stores/' . Mage::app()-&gt;getStore()-&gt;getId() . $file;
          } elseif ( $this-&gt;_fileExists($baseDir . '/watermark/websites/' . Mage::app()-&gt;getWebsite()-&gt;getId() . $file) ) {
              $filePath = $baseDir . '/watermark/websites/' . Mage::app()-&gt;getWebsite()-&gt;getId() . $file;
          } elseif ( $this-&gt;_fileExists($baseDir . '/watermark/default/' . $file) ) {
              $filePath = $baseDir . '/watermark/default/' . $file;
          } elseif ( $this-&gt;_fileExists($baseDir . '/watermark/' . $file) ) {
              $filePath = $baseDir . '/watermark/' . $file;
          } else {
              $baseDir = Mage::getDesign()-&gt;getSkinBaseDir();
              if( $this-&gt;_fileExists($baseDir . $file) ) {
                  $filePath = $baseDir . $file;
              }
          }
  
          return $filePath;
      }
  </code></pre>