thedoggydog
thedoggydog

Reputation: 469

Pictures Broken After Transferring To New Server

I have a WordPress website using the shopp eCommerce plugin which I moved from MediaTemple to HostGator VPS.

Link: http://www.shop.deltagrooveproductions.com

After I transferred the pictures on the store all all broken images. When you try to open the image in a new tab there are PHP errors. This link for example: http://www.shop.deltagrooveproductions.com/shop/images/2338/TerryHank_GottaBringItOnHomeToYou_AlbumArt.png

There pictures are stored in the database but I have no clue why they aren't loading now that I transferred.

Here is the source code to Assets.php

class FileAsset extends MetaObject {

var $mime;
var $size;
var $storage;
var $uri;
var $context = 'product';
var $type = 'asset';
var $_xcols = array('mime','size','storage','uri');

function __construct ($id=false) {
    $this->init(self::$table);
    $this->extensions();
    if (!$id) return;
    $this->load($id);

    if (!empty($this->id))
        $this->expopulate();
}


/**
 * Populate extended fields loaded from the MetaObject
 *
 * @author Jonathan Davis
 * @since 1.1
 *
 * @return void
 **/
function expopulate () {
    parent::expopulate();
    $this->uri = stripslashes($this->uri);
}

/**
 * Store the file data using the preferred storage engine
 *
 * @author Jonathan Davis
 * @since 1.1
 *
 * @return void
 **/
function store ($data,$type='binary') {
    $Engine = $this->_engine();
    $this->uri = $Engine->save($this,$data,$type);
    if ($this->uri === false) return false;
    return true;
}

/**
 * Retrieve the resource data
 *
 * @author Jonathan Davis
 * @since 1.1
 *
 * @return void
 **/
function retrieve () {
    $Engine = $this->_engine();
    return $Engine->load($this->uri);
}

/**
 * Retreive resource meta information
 *
 * @author Jonathan Davis
 * @since 1.1
 *
 * @return void
 **/
function readmeta () {
    $Engine = $this->_engine();
    list($this->size,$this->mime) = array_values($Engine->meta($this->uri,$this->name));
}

/**
 * Determine if the resource exists
 *
 * @author Jonathan Davis
 * @since 1.1
 *
 * @return void
 **/
function found ($uri=false) {
    if (!empty($this->data)) return true;
    if (!$uri) $uri = $this->uri;
    $Engine = $this->_engine();
    return $Engine->exists($uri);
}

/**
 * Determine the storage engine to use
 *
 * @author Jonathan Davis
 * @since 1.1
 *
 * @return void Description...
 **/
function &_engine () {
    global $Shopp;
    if (!isset($Shopp->Storage)) $Shopp->Storage = new StorageEngines();

    if (!empty($this->storage)) {
        // Use the storage engine setting of the asset
        if (isset($Shopp->Storage->active[$this->storage])) {
            $Engine = $Shopp->Storage->active[$this->storage];
        } else if (isset($Shopp->Storage->modules[$this->storage])) {
            $Module = new ModuleFile(SHOPP_STORAGE,$Shopp->Storage->modules[$this->storage]->filename);
            $Engine = $Module->load();
        }
    } elseif (isset($Shopp->Storage->engines[$this->type])) {
        // Pick storage engine from Shopp-loaded engines by type of asset
        $engine = $Shopp->Storage->engines[$this->type];
        $this->storage = $engine;
        $Engine = $Shopp->Storage->active[$engine];
    }
    if (!empty($Engine)) $Engine->context($this->type);

    return $Engine;
}

/**
 * Stub for extensions
 *
 * @author Jonathan Davis
 * @since 1.1
 *
 * @return void
 **/
function extensions () {}

} // END class FileAsset

/**
 * ImageAsset class
 *
 * A specific implementation of the FileAsset class that provides helper
 * methods for imaging-specific tasks.
 *
 * @author Jonathan Davis
 * @since 1.1
 * @package shopp
 **/
class ImageAsset extends FileAsset {

// Allowable settings
var $_scaling = array('all','matte','crop','width','height');
var $_sharpen = 500;
var $_quality = 100;

var $width;
var $height;
var $alt;
var $title;
var $settings;
var $filename;
var $type = 'image';

function output ($headers=true) {

    if ($headers) {
        $Engine = $this->_engine();
        $data = $this->retrieve($this->uri);

        $etag = md5($data);
        $offset = 31536000;

        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
            if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $this->modified ||
                trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
                header("HTTP/1.1 304 Not Modified");
                header("Content-type: {$this->mime}");
                exit;
            }
        }

        header("Cache-Control: public, max-age=$offset");
        header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $offset ) . ' GMT');
        header('Last-Modified: '.date('D, d M Y H:i:s', $this->modified).' GMT');
        if (!empty($etag)) header('ETag: '.$etag);

        header("Content-type: $this->mime");

        $filename = empty($this->filename) ? "image-$this->id.jpg" : $this->filename;
        header('Content-Disposition: inline; filename="'.$filename.'"');
        header("Content-Description: Delivered by WordPress/Shopp Image Server ({$this->storage})");
    }

Any ideas?

Upvotes: 0

Views: 203

Answers (1)

RST
RST

Reputation: 3925

You probably solved it by re-saving the permalinks. This is often necessary after updating, transferring Shopp.

You should consider changing from database-storage to file-storage. It is not a good idea to have many images in the database. It is slower too.

There is a free plugin that can help you with it. Always backup your files and database before making changes like this.

Upvotes: 0

Related Questions