Skip to content

Commit

Permalink
Don't remove media files if referenced more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed May 11, 2019
1 parent 1537182 commit 63c8537
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions controller/common/src/Controller/Common/Media/Standard.php
Expand Up @@ -87,6 +87,14 @@ public function add( \Aimeos\MShop\Media\Item\Iface $item, \Psr\Http\Message\Upl
*/
public function delete( \Aimeos\MShop\Media\Item\Iface $item, $fsname = 'fs-media' )
{
$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'media' );
$search = $manager->createSearch()->setSlice( 0, 2 );
$search->setConditions( $search->compare( '==', 'media.url', $item->getUrl() ) );

if( count( $manager->searchItems( $search ) ) > 1 ) {
return $this;
}

$fs = $this->context->getFilesystemManager()->get( $fsname );

$path = $item->getUrl();
Expand Down Expand Up @@ -468,7 +476,7 @@ protected function scaleImage( \Aimeos\MW\Media\Image\Iface $media, $type )
* @category User
*/
$maxheight = $config->get( 'controller/common/media/standard/' . $type . '/maxheight', null );

/** controller/common/media/standard/files/force-size
* Force exact image size for the uploaded images
*
Expand All @@ -484,7 +492,7 @@ protected function scaleImage( \Aimeos\MW\Media\Image\Iface $media, $type )
* @category Developer
* @category User
*/

/** controller/common/media/standard/preview/force-size
* Force exact image size for the preview images
*
Expand Down

0 comments on commit 63c8537

Please sign in to comment.