Skip to content

Instantly share code, notes, and snippets.

@hprange
Forked from samukasmk/smk_magento_resizer.php
Last active December 23, 2015 14:59

Revisions

  1. hprange revised this gist Sep 21, 2013. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion smk_magento_resizer.php
    Original file line number Diff line number Diff line change
    @@ -55,9 +55,12 @@
    // main image of homepage/catalog
    echo Mage::helper('catalog/image')->init($products, 'small_image')->resize(312);
    echo "<br>";
    // main image of product page
    // main large size image of product page
    echo Mage::helper('catalog/image')->init($products, 'image')->resize(1000,1000);
    echo "<br>";
    // main small size image of product page
    echo Mage::helper('catalog/image')->init($products, 'image')->resize(470,470);
    echo "<br>";
    // thumbnails images of product page
    echo Mage::helper('catalog/image')->init($products, 'thumbnail')->resize(140,140);
    echo "<br>";
  2. hprange revised this gist Sep 21, 2013. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions smk_magento_resizer.php
    Original file line number Diff line number Diff line change
    @@ -26,16 +26,16 @@
    For execute in command line:
    -> Put this script in your magento root path:
    EG:
    # cd /var/www/html/my_magento_folder
    curl -O smk_magento_resizer.php
    $ cd /var/www/html/my_magento_folder
    $ curl -O smk_magento_resizer.php
    -> Running resize images creation
    # curl -L http://my-magento.com/smk_magento_resizer.php
    $ curl -L http://my-magento.com/smk_magento_resizer.php
    -> If you prefer, set this call in cron
    # crontab -e
    $ crontab -e
    ----
    # 5 * * * * curl -L http://my-magento.com/smk_magento_resizer.php
    5 * * * * curl -L http://my-magento.com/smk_magento_resizer.php
    */

    ini_set('display_errors','on');
  3. hprange revised this gist Sep 21, 2013. 1 changed file with 1 addition and 10 deletions.
    11 changes: 1 addition & 10 deletions smk_magento_resizer.php
    Original file line number Diff line number Diff line change
    @@ -66,16 +66,7 @@
    echo "<br>";
    // thumbnails images of product cart
    echo Mage::helper('catalog/image')->init($products, 'thumbnail')->resize(75);
    echo "<br>";

    // echo "<pre>";
    //print_r($products);
    // echo $products->getImage();
    // echo "<br>";
    // echo $products->getSmallImage();
    // echo "<br>";
    // echo $products->getThumbnail();
    // echo "<br>";
    echo "<br>";
    }

    ?>
  4. @samukasmk samukasmk revised this gist Aug 29, 2013. 1 changed file with 10 additions and 4 deletions.
    14 changes: 10 additions & 4 deletions smk_magento_resizer.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    <?php
    /*
    smk_magento_resizer.php
    smk_magento_resizer.php
    Resizes Images for isolated/specific magento (admin) server
    @@ -48,7 +48,7 @@
    foreach ($collection as $product) {

    $products = Mage::getModel('catalog/product')->load($product->getId());

    echo "---";
    echo "<br>";
    /* resize functions is used to resize image */
    @@ -60,8 +60,14 @@
    echo "<br>";
    // thumbnails images of product page
    echo Mage::helper('catalog/image')->init($products, 'thumbnail')->resize(140,140);
    echo "<br>";

    echo "<br>";
    // image of product in cart
    echo Mage::helper('catalog/image')->init($products, 'small_image')->resize(88,77);
    echo "<br>";
    // thumbnails images of product cart
    echo Mage::helper('catalog/image')->init($products, 'thumbnail')->resize(75);
    echo "<br>";

    // echo "<pre>";
    //print_r($products);
    // echo $products->getImage();
  5. @samukasmk samukasmk revised this gist Aug 28, 2013. 1 changed file with 19 additions and 19 deletions.
    38 changes: 19 additions & 19 deletions smk_magento_resizer.php
    Original file line number Diff line number Diff line change
    @@ -47,29 +47,29 @@

    foreach ($collection as $product) {

    $products = Mage::getModel('catalog/product')->load($product->getId());

    echo "---";
    echo "<br>";
    /* resize functions is used to resize image */
    // main image of homepage/catalog
    $products = Mage::getModel('catalog/product')->load($product->getId());
    echo "---";
    echo "<br>";
    /* resize functions is used to resize image */
    // main image of homepage/catalog
    echo Mage::helper('catalog/image')->init($products, 'small_image')->resize(312);
    echo "<br>";
    // main image of product page
    echo "<br>";
    // main image of product page
    echo Mage::helper('catalog/image')->init($products, 'image')->resize(1000,1000);
    echo "<br>";
    // thumbnails images of product page
    echo "<br>";
    // thumbnails images of product page
    echo Mage::helper('catalog/image')->init($products, 'thumbnail')->resize(140,140);
    echo "<br>";

    echo "<br>";
    // echo "<pre>";
    //print_r($products);
    // echo $products->getImage();
    // echo "<br>";
    // echo $products->getSmallImage();
    // echo "<br>";
    // echo $products->getThumbnail();
    // echo "<br>";
    //print_r($products);
    // echo $products->getImage();
    // echo "<br>";
    // echo $products->getSmallImage();
    // echo "<br>";
    // echo $products->getThumbnail();
    // echo "<br>";
    }

    ?>
  6. @samukasmk samukasmk created this gist Aug 28, 2013.
    75 changes: 75 additions & 0 deletions smk_magento_resizer.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,75 @@
    <?php
    /*
    smk_magento_resizer.php
    Resizes Images for isolated/specific magento (admin) server
    Created By: Samuel Maciel Sampaio ([email protected]) [20130828]
    References where I got the core:
    http://stackoverflow.com/questions/2474117/how-to-get-a-products-image-in-magento
    http://stackoverflow.com/questions/10426210/how-to-get-product-image-in-magento
    Special Thanks for stackoverflow users:
    Suman-PHP4U (http://stackoverflow.com/users/795510/suman-php4u)
    silvo (http://stackoverflow.com/users/295614/silvo)
    Ricardo Martins (http://stackoverflow.com/users/529403/ricardo-martins)
    Mitch Thompson (http://stackoverflow.com/users/1399382/mitch-thompson)
    gowri (http://stackoverflow.com/users/430112/gowri)
    alex (http://stackoverflow.com/users/297028/alex)
    daveshaw (http://stackoverflow.com/users/383710/daveshaw)
    Suma Gowda (http://stackoverflow.com/users/1284719/suma-gowda)
    Vikrant 33 (http://stackoverflow.com/users/1379084/vikrant-33)
    Andriy M (http://stackoverflow.com/users/297408/andriy-m)
    Shiv Kumar (http://stackoverflow.com/users/1226172/shiv-kumar)
    For execute in command line:
    -> Put this script in your magento root path:
    EG:
    # cd /var/www/html/my_magento_folder
    curl -O smk_magento_resizer.php
    -> Running resize images creation
    # curl -L http://my-magento.com/smk_magento_resizer.php
    -> If you prefer, set this call in cron
    # crontab -e
    ----
    # 5 * * * * curl -L http://my-magento.com/smk_magento_resizer.php
    */

    ini_set('display_errors','on');
    require_once 'app/Mage.php';
    Mage::app('default');


    $collection = Mage::getModel('catalog/product')->getCollection();

    foreach ($collection as $product) {

    $products = Mage::getModel('catalog/product')->load($product->getId());

    echo "---";
    echo "<br>";
    /* resize functions is used to resize image */
    // main image of homepage/catalog
    echo Mage::helper('catalog/image')->init($products, 'small_image')->resize(312);
    echo "<br>";
    // main image of product page
    echo Mage::helper('catalog/image')->init($products, 'image')->resize(1000,1000);
    echo "<br>";
    // thumbnails images of product page
    echo Mage::helper('catalog/image')->init($products, 'thumbnail')->resize(140,140);
    echo "<br>";

    // echo "<pre>";
    //print_r($products);
    // echo $products->getImage();
    // echo "<br>";
    // echo $products->getSmallImage();
    // echo "<br>";
    // echo $products->getThumbnail();
    // echo "<br>";
    }

    ?>