Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Console/Command/ThumbnailShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ThumbnailShell extends AppShell {
*/
public function getOptionParser() {
$parser = parent::getOptionParser();
$parser->addSubcommand('generate', ['help' => 'Find models and regenerate the thumbnails.']);
$parser->addSubcommand('generate', array('help' => 'Find models and regenerate the thumbnails.'));
return $parser;
}

Expand Down Expand Up @@ -62,12 +62,12 @@ public function generate() {
'rootDir' => $mergedConfig['rootDir'],
);

$files = $this->{$modelName}->find('all', [
$files = $this->{$modelName}->find('all', array(
'fields' => [$this->{$modelName}->primaryKey, $field, $mergedConfig['fields']['dir']],
'conditions' => [
'conditions' => array(
$field . " IS NOT NULL"
]
]);
)
));

foreach ($files as $file) {
$this->{$modelName}->Behaviors->load('ShellUpload', $behaviorConfig);
Expand All @@ -79,19 +79,19 @@ public function generate() {
}

// $field needs to be an array like uploading an image
$fieldData = [
$fieldData = array(
'name' => basename($sourceFilePath),
'type' => mime_content_type($sourceFilePath),
'size' => filesize($sourceFilePath),
'tmp_name' => $sourceFilePath,
'error' => UPLOAD_ERR_OK
];
);

$data = [
$data = array(
$this->{$modelName}->primaryKey => $file[$modelName][$this->{$modelName}->primaryKey],
$field => $fieldData,
$config['fields']['dir'] => $file[$modelName][$this->{$modelName}->primaryKey],
];
);

if ($this->{$modelName}->hasField('modified')) {
$data['modified'] = false;
Expand All @@ -107,4 +107,4 @@ public function generate() {
}
}
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Media Plugin is too complicated, and it was a PITA to merge the latest updates i

* CakePHP 2.x
* Imagick/GD PHP Extension (for thumbnail creation)
* PHP 5
* PHP 5.3+
* Patience

## Documentation
Expand Down