public function Textimage::load in Textimage 7.3
Load Textimage metadata from store.
If the image file is missing at URI, it is rebuilt.
Parameters
string $id: The id of the Textimage to load.
Return value
self this object
File
- classes/
Textimage.inc, line 356 - Textimage - Textimage class.
Class
- Textimage
- @file Textimage - Textimage class.
Code
public function load($id) {
// Do not re-process.
if ($this->processed) {
return $this;
}
// Check if we have the hash in store.
$stored_image = db_select('textimage_store', 'ic')
->fields('ic')
->condition('tiid', $id, '=')
->execute()
->fetchAssoc();
// Not in stock, return.
if (!$stored_image) {
return $this;
}
// Restore properties.
$this->id = $stored_image['tiid'];
$is_void = $stored_image['is_void'];
$this
->styleByName($stored_image['style_name']);
if ($is_void) {
$this->effects = unserialize($stored_image['effects_outline']);
}
$this->imageData = unserialize($stored_image['image_data']);
$this->text = $this->imageData['text'];
$this->extension = $this->imageData['extension'];
if (!empty($this->imageData['forceHashedFilename'])) {
$this->forceHashedFilename = $this->imageData['forceHashedFilename'];
}
$this->timer = $stored_image['timer'];
// In stock, check file is there.
if (is_file($stored_image['uri'])) {
$this->uri = $stored_image['uri'];
$this->processed = TRUE;
}
else {
// If not, rebuild image file.
$this
->buildImage();
}
return $this;
}