Announcement

#1 2010-08-17 15:38:27

Birtles
Member
2010-04-16
43

Delete photos by rating

Hi, is it possible to select a certain group of immages by rating (say all images rated with one star) and delete them from the database? with 14000 images in our database, some of them are bound to just waste space and therefore would be suitable for deletion. I have asked other employees to mark photos with one star that are deletable. if it was just me, the administrator i could add the images to caddy, i know. But it is not just me, admin, but also normal users.

Offline

 

#2 2010-08-17 16:23:28

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13277

Re: Delete photos by rating

Hi Birtles,

In the web interface, you can only delete photos added with another method than synchronization (ie pLoader or web upload are OK).

There is currently no way to "select by rating" (but I can add this feature in the future bulk manager I'm working on) in the web interface but we can make a "personal plugin" to automatically fill your caddie with 1 star photos.

Offline

 

#3 2010-08-17 17:45:20

Birtles
Member
2010-04-16
43

Re: Delete photos by rating

That would be great! Ill have one of those personal plugins please :)

Offline

 

#4 2010-08-18 14:36:32

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13277

Re: Delete photos by rating

1) activate the LocalFiles Editor plugin

2) go to [Administration > Plugins > LocalFiles Editor > Personal Plugin] and paste the following code:

Code:

<?php
/*
Plugin Name: Personal Plugin
Version: 1.0
Description: Personal Plugin
Plugin URI: http://piwigo.org
Author:
Author URI:
*/

add_event_handler('loc_begin_admin', 'refresh_caddie');
function refresh_caddie()
{
  global $user;

  if (!isset($_GET['page']) or 'element_set' != $_GET['page'])
  {
    return null;
  }

  if (!isset($_GET['cat']) or 'caddie' != $_GET['cat'])
  {
    return null;
  }

  // empty the caddie
  $query = '
DELETE
  FROM '.CADDIE_TABLE.'
  WHERE user_id = '.$user['id'].'
;';
  pwg_query($query);

  // find all photos with a given rating
  $query = '
SELECT id
  FROM '.IMAGES_TABLE.'
  WHERE average_rate < 1.5
;';
  $image_ids = array_from_query($query, 'id');

  // fill the caddie with the found photos
  $datas = array();
  foreach ($image_ids as $image_id)
  {
    array_push(
      $datas,
      array(
        'user_id' => $user['id'],
        'element_id' => $image_id,
      )
    );
  }
  mass_inserts(
    CADDIE_TABLE,
    array_keys($datas[0]),
    $datas
  );
}
?>

3) go to [Administration > Plugins > Manage], install and activate the "Personal Plugin"

4) go to [Administration > Photos > Caddie], it will be automatically filled with photos rated less than 1.5 (as average rate)

Once you have finished with this administration task, deactivate the Personal Plugin to avoid wondering why you don't find the photos you manually added in the caddie.

Offline

 

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2019 · Contact