delete photos

jjreina

Joined: 2010-03-08
Posts: 22
Posted: Wed, 2010-03-17 08:21

How do I delete photos by code?

Very Thx

 
jjreina

Joined: 2010-03-08
Posts: 22
Posted: Wed, 2010-03-17 09:44

I'm trying whith this:

require_once("../gallery2/embed.php");
$ret = GalleryCoreApi::deleteEntityById(45, 'GalleryItem');
if ($ret)
{
return array($ret, null);
}

but nothing..

Thanks.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2010-03-17 12:06
 
jjreina

Joined: 2010-03-08
Posts: 22
Posted: Wed, 2010-03-17 12:27

thanks for answering, but still no sign remove the photo

require_once("../gallery2/embed.php");
$ret = GalleryEmbed::init(array('fullInit' => true, 'g2Uri' => '/gallery2/main.php'));
$ret = GalleryCoreApi::deleteEntityById(45, 'GalleryItem');
if ($ret)
{
return $ret;
}

return null;
?>

Sorry but i'm very noob.

Thanks

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2010-03-17 12:46
function init() {
    require_once ('embed.php');
    $ret = GalleryEmbed::init(array('fullInit'=>true));
    if ($ret) {
        print 'GalleryEmbed::init failed, here is the error message: '.$ret->getAsHtml();
        exit;
    }
    GalleryEmbed::done();
}

init();
$ret = GalleryCoreApi::deleteEntityById(45, 'GalleryItem');
if ($ret){
    print 'GalleryCoreApi::deleteEntityById failed, here is the error message: '.$ret->getAsHtml();
    exit;
}
return 'success'; // or TRUE

$ret will be null if there is no error, so return/print success or true if you're expecting a response.
and I believe the correct EntityType is required now GalleryAlbumItem, GalleryPhotoItem, GalleryUser ...
http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryCoreApi.html#methoddeleteEntityById

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
jjreina

Joined: 2010-03-08
Posts: 22
Posted: Wed, 2010-03-17 12:58

Thank you very much, now if you delete the photo

thanks

 
jjreina

Joined: 2010-03-08
Posts: 22
Posted: Thu, 2010-03-18 08:56

Hello, I can not delete a picture, this code removes a full album.

Any suggestions?

thank you very much

 
jjreina

Joined: 2010-03-08
Posts: 22
Posted: Thu, 2010-03-18 16:01

I use to remove a photo:
$ret = GalleryCoreApi::deleteEntityById(88,'GalleryPhotoItem');

but not detele photo
pls help me. thanks

 
jjreina

Joined: 2010-03-08
Posts: 22
Posted: Fri, 2010-03-19 13:01

I've also tried ant nothigs:

list($ret, $user) = GalleryCoreApi::fetchUserByUsername("postgres");
$gallery->setActiveUser($user);

//get GalleryItem by itemId
list ($ret, $item) = GalleryCoreApi::loadEntitiesById(37,'GalleryPhotoItem');

print $item->getId() ;
print $item->getTitle();
print $item->getEntityType();
$item->releaseAllLocks( );

$ret = $item->delete();
if ($ret)
{
print 'GalleryCoreApi::deleteEntityById failed,
here is the error message: '.$ret->getAsHtml();
exit;
}

Please, Any suggestions?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2010-03-22 12:09
Quote:
list ($ret, $item) = GalleryCoreApi::loadEntitiesById(37,'GalleryPhotoItem');

I assume 37 is the id of the photoItem you are trying to delete?
not the thumbnail, not the resize, not any derivative... the original photo

I ask because 37 is a very low number, it would have had to be one of the first items you added to your gallery.
and above you are trying to delete item 88

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
jjreina

Joined: 2010-03-08
Posts: 22
Posted: Mon, 2010-03-22 12:29

La imagen original es la id = 37, es un numero bajo porque es una gallery de prueba con una sola imagen.

gracias por contestar.

Sorry i did wrtite in spanish.

The original image is the id = 37, is a low number because it is a test gallery with a single image.

thanks for answering.

If i do:
$ret = GalleryCoreApi::deleteEntityById(37, 'GalleryPhotoItem');
and next:
list ($ret2, $item) = GalleryCoreApi::loadEntitiesById(37, 'GalleryPhotoItem');
I get the error:
GalleryCoreApi::loadEntitiesById failed, here is the error message: Error (ERROR_MISSING_OBJECT) : Missing object for 37.

Presumably the photo was deleted, but not eliminated Gallery2.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2010-03-22 12:32

Then the item was deleted.
try clearing the cache

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
jjreina

Joined: 2010-03-08
Posts: 22
Posted: Mon, 2010-03-22 12:47

nothing, I don't know to try :(

It should be easy to remove a photo...

Thanks for help me.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2010-03-22 13:11

I've never tried removing a photo using the API, any reason you are not using the UI?

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
jjreina

Joined: 2010-03-08
Posts: 22
Posted: Mon, 2010-03-22 21:48

I need struct of gallery2 (data base) but no UI

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2010-03-22 22:42

Gallery's Embed API allows for you to interact with gallery in most normal ways.
Including embedding gallery within your page(s) leaving gallery's MVC to manipulate the data.
my site has gallery fully embedded allowing for user mapping between both applications.
You can also do a simple embed without user mapping.

There are also other ways to display gallery content outside of gallery:
http://www.flashyourweb.com/staticpages/index.php?page=mediaBlock
http://www.flashyourweb.com/staticpages/index.php?page=TheMiniSlideShow
http://www.flashyourweb.com/staticpages/index.php?page=TheExecutive

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
jjreina

Joined: 2010-03-08
Posts: 22
Posted: Tue, 2010-03-23 09:21

Thanks you very much suprdir,
solved, just put GalleryEmbed::done(), next the codec.

Thx for help me xxD.