bmcclure / CakePHP-Media-Plugin

A CakePHP (2.0) plugin enabling transfer/manipulation/embedding of files in 23 ways.
Other
60 stars 24 forks source link

Deleting all versions of an image #8

Closed PHANTOMIAS closed 12 years ago

PHANTOMIAS commented 12 years ago

I upload an image and generate automatically different versions. Deleting a record which has an image, should also delete all versions of this image.

So I found this tutorial: https://github.com/davidpersson/media/blob/next/docs/TUTORIAL

There is a function: public function beforeDelete($cascade = true)

This one is called, but this line returns an error: $versions = array_keys(Configure::read('Media.filter.' . $name)); This is caused by Configure::read('Media.filter.' . $name)

$name is "image", so the call is Configure::read('Media.filter.image') and this returns NULL.

So the question is, why? In my Plugin/Media/Config/core.php I did not change these lines, so it should work?

Configure::write('Media.filter', array('default' => array( 'audio' => compact('s', 'm'), 'document' => compact('s', 'm'), 'generic' => array(), 'image' => compact('s', 'm'), 'video' => compact('s', 'm') )));

Is there a problem because of CakePHP 2.0?

PHANTOMIAS commented 12 years ago

Solved. This line $versions = array_keys(Configure::read('Media.filter.' . $name)); should be replaced with this line $versions = array_keys(Configure::read('Media.filter.default.' . $name));

That's all :-)