When you call pwg.categories.getImages for a category, all resources are returned with just a single category in their list of categories. This is regardless of how many they are linked to.
This is an issue if you then wish to unlink a resource(s) (e.g. image), because you do not know whether it will result in an orphan unless you first do a call to get the details of that/those image(s) pwg.images.getInfo. This is inefficient.
Given the api appears to return a list of categories, I'd expect it to do so. It seems pointless to just return the one that you requested the images list for using pwg.categories.getImages.
When you call pwg.categories.getImages for a category, all resources are returned with just a single category in their list of categories. This is regardless of how many they are linked to.
This is an issue if you then wish to unlink a resource(s) (e.g. image), because you do not know whether it will result in an orphan unless you first do a call to get the details of that/those image(s) pwg.images.getInfo. This is inefficient.
Given the api appears to return a list of categories, I'd expect it to do so. It seems pointless to just return the one that you requested the images list for using pwg.categories.getImages.
<!-- github-sync-id:274254506 -->
Hi,
I am wondering if it is possible to get several images from several albums (e.g 3 images from each of 5 categories) in one query? The way to do several requests for this task looks a bit ugly solution, and there is not much documentation on the API.
Hi,
I am wondering if it is possible to get several images from several albums (e.g 3 images from each of 5 categories) in one query? The way to do several requests for this task looks a bit ugly solution, and there is not much documentation on the API.
<!-- github-comment-id:565434209 -->
Your comment sounds interesting, but this should be raised as a separate issue. The issue I've raised is very different, referring to the list of linked albums returned for each resource when you retrieve the resources in a category.
Your comment sounds interesting, but this should be raised as a separate issue. The issue I've raised is very different, referring to the list of linked albums returned for each resource when you retrieve the resources in a category.
<!-- github-comment-id:565699813 -->
Thanks for your attention. I found not much developers activity on this API, so decided to ask in a live thread close to the issue. Also posted this question to PIWI forum. Finally decided to query PIWI DB directly, this appeared to be the fastest and the simpliest method...
Sorry for off-topic message.
Thanks for your attention. I found not much developers activity on this API, so decided to ask in a live thread close to the issue. Also posted this question to PIWI forum. Finally decided to query PIWI DB directly, this appeared to be the fastest and the simpliest method...
Sorry for off-topic message.
<!-- github-comment-id:566444100 -->
As discussed with @remi-martin yesterday we indeed have to fix this bug. But the result might not be what you expect. I explain. Currently pwg.categories.getImages returns only one category (the current one, a bit useless, to say the least). I can work on it to fix it and provide the same list of categories as the one we see on the page of the photo (picture.php). That would not be the "full" list of albums. Indeed the photo can perfectly be linked to other albums but you don't see them because you don't have access to them.
Reminder: even administrators are subject to the permission system.
In first conclusion: you won't be able to predict a photo would become orphan simply by relying on the list of albums returned by pwg.categories.getImages (or by pwg.images.getInfo by the way). To do that, we could have a second list of "all categories", only provided when connected as administrator.
As discussed with @remi-martin yesterday we indeed have to fix this bug. But the result might not be what you expect. I explain. Currently `pwg.categories.getImages` returns only one category (the current one, a bit useless, to say the least). I can work on it to fix it and provide the same list of categories as the one we see on the page of the photo (picture.php). That would not be the "full" list of albums. Indeed the photo can perfectly be linked to other albums but you don't see them because you don't have access to them.
Reminder: even administrators are subject to the permission system.
In first conclusion: you won't be able to predict a photo would become orphan simply by relying on the list of albums returned by `pwg.categories.getImages` (or by `pwg.images.getInfo` by the way). To do that, we could have a second list of "all categories", only provided when connected as administrator.
<!-- github-comment-id:938599518 -->
Hello there, in piwigo 12 we plan to implement a method called pwg.categories.calculateOrphans, which as it names says, calculates and returns the orphans that would be created if you delete a category. I hope it will help you.
Hello there, in piwigo 12 we plan to implement a method called pwg.categories.calculateOrphans, which as it names says, calculates and returns the orphans that would be created if you delete a category. I hope it will help you.
<!-- github-comment-id:939983932 -->
Thanks for looking into this issue.
Returning the list of categories to which the user has access would be what is expected and would avoid us to have to call the pwg.images.getInfo method repeatedly. From this data, we will be able to determine which images belong to which albums and which ones would become orphans if the user deletes an album (as seen by the user).
We could then propose the user to copy images to another album by calling the pwg.images.setInfo method with multiple_value_mode=append for appending the category ID of the targeted album.
For moving images, I expect that we could use the same method with multiple_value_mode=replace for replacing the list of category IDs "belonging to the user". @plg, do you confirm that the method only replaces the list of albums to which the user has access (i.e. the lists provided by pwg.categories.getImages and pwg.images.getInfo)?
And for deleting images, the method pwg.images.delete does the job.
As for the proposed pwg.categories.calculateOrphans method, I do not believe that we really need it because it would return an information we can deduce from a call to the pwg.categories.getImages method without having to make an additional URL request draining the battery of a mobile (it would also be much faster).
I would prefer a method pwg.categories.getOrphans which returns the list of "true orphans" to admins in a format which can be used to display a virtual album of "true orphans" (output similar to pwg.users.favorites.getList).
Thanks for looking into this issue.
Returning the list of categories to which the user has access would be what is expected and would avoid us to have to call the `pwg.images.getInfo` method repeatedly. From this data, we will be able to determine which images belong to which albums and which ones would become orphans if the user deletes an album (as seen by the user).
- We could then propose the user to copy images to another album by calling the `pwg.images.setInfo` method with `multiple_value_mode=append` for appending the category ID of the targeted album.
- For moving images, I expect that we could use the same method with `multiple_value_mode=replace` for replacing the list of category IDs "belonging to the user". @plg, do you confirm that the method only replaces the list of albums to which the user has access (i.e. the lists provided by `pwg.categories.getImages` and `pwg.images.getInfo`)?
- And for deleting images, the method `pwg.images.delete` does the job.
As for the proposed `pwg.categories.calculateOrphans` method, I do not believe that we really need it because it would return an information we can deduce from a call to the `pwg.categories.getImages` method without having to make an additional URL request draining the battery of a mobile (it would also be much faster).
I would prefer a method `pwg.categories.getOrphans` which returns the list of "true orphans" to admins in a format which can be used to display a virtual album of "true orphans" (output similar to `pwg.users.favorites.getList`).
<!-- github-comment-id:941029157 -->
Warning: pwg.images.getInfo only returns the list of categories accessible to the current user. Not all categories. So you can absolutely not know if the photo would become orphan if you delete an album. Not reliable at all.
Currently, with multiple_value_mode in {append, replace} you should be able to associate/move/dissociate to albums. The limit is that you have to call pwg.images.setInfo for each photo. We've been discussing this topic with @remi-martin and he suggests we had a new method pwg.images.setCategory with 3 parameters :
image_ids (can be a list, that's the whole point)
action {associate, dissociate, move}
category_id
I like this idea. Much more simple to associate/dissociate images to/from albums. We could also have a specific method for each action : pwg.images.associateToCategory + pwg.images.dissociateFromCategory + pwg.images.moveToCategory (or pwg.images.category.associateTo + pwg.images.category.dissociateFrom + pwg.images.category.moveTo)
As for the proposed pwg.categories.calculateOrphans method, I do not believe
that we really need it because it would return an information we can deduce from
a call to the pwg.categories.getImages
No, you can't deduce the "would be" orphans with pwg.categories.getImages, unless we add a new output field "categories_admin_list" which would not take permissions into account.
The pwg.categories.calculateOrphans method has been added by @MatthieuLP to make the computation as less often as possible, because it's an heavy one and it's useful only a very few times compared to the number of requests to pwg.categories.getImages.
pwg.categories.getOrphans
You mean pwg.images.getOrphans because if a photo is associate to a category then it can't be an orphan. So it would be mean "list of orphans if we delete this category" and it would be the exact same as pwg.categories.calculateOrphans. Please give me more details :-)
Warning: `pwg.images.getInfo` only returns the list of categories accessible to the current user. Not all categories. So you can absolutely not know if the photo would become orphan if you delete an album. Not reliable at all.
Currently, with `multiple_value_mode` in {append, replace} you should be able to associate/move/dissociate to albums. The limit is that you have to call `pwg.images.setInfo` for each photo. We've been discussing this topic with @remi-martin and he suggests we had a new method `pwg.images.setCategory` with 3 parameters :
1. image_ids (can be a list, that's the whole point)
2. action {associate, dissociate, move}
3. category_id
I like this idea. Much more simple to associate/dissociate images to/from albums. We could also have a specific method for each action : `pwg.images.associateToCategory` + `pwg.images.dissociateFromCategory` + `pwg.images.moveToCategory` (or `pwg.images.category.associateTo` + `pwg.images.category.dissociateFrom` + `pwg.images.category.moveTo`)
> As for the proposed `pwg.categories.calculateOrphans` method, I do not believe
> that we really need it because it would return an information we can deduce from
> a call to the `pwg.categories.getImages`
No, you can't deduce the "would be" orphans with `pwg.categories.getImages`, unless we add a new output field "categories_admin_list" which would not take permissions into account.
The `pwg.categories.calculateOrphans` method has been added by @MatthieuLP to make the computation as less often as possible, because it's an heavy one and it's useful only a very few times compared to the number of requests to `pwg.categories.getImages`.
> `pwg.categories.getOrphans`
You mean `pwg.images.getOrphans` because if a photo is associate to a category then it can't be an orphan. So it would be mean "list of orphans if we delete this category" and it would be the exact same as `pwg.categories.calculateOrphans`. Please give me more details :-)
<!-- github-comment-id:944392667 -->
Warning: pwg.images.getInfo only returns the list of categories accessible to the current user. Not all categories. So you can absolutely not know if the photo would become orphan if you delete an album. Not reliable at all.
This is not reliable (incomplete) for an admin looking for orphans globally on a server, but this is perfectly fine for an admin or non-admin user managing his/her own photos i.e. for most usages. We miss a user status allowing to create/delete/move/etc. albums and upload/delete/edit photos/videos without access to server management tools.
Currently, with multiple_value_mode in {append, replace} you should be able to associate/move/dissociate to albums. The limit is that you have to call pwg.images.setInfo for each photo. We've been discussing this topic with @remi-martin and he suggests we had a new method pwg.images.setCategory with 3 parameters :
image_ids (can be a list, that's the whole point)
action {associate, dissociate, move}
category_id
I like this idea. Much more simple to associate/dissociate images to/from albums. We could also have a specific method for each action : pwg.images.associateToCategory + pwg.images.dissociateFromCategory + pwg.images.moveToCategory (or pwg.images.category.associateTo + pwg.images.category.dissociateFrom + pwg.images.category.moveTo)
Sure, a single call would be much more efficient. Similarly, I would welcome an update of the methods pwg.users.favorites.add and pwg.users.favorites.remove because we must call them repeatedly.
As for the proposed pwg.categories.calculateOrphans method, I do not believe
that we really need it because it would return an information we can deduce from
a call to the pwg.categories.getImages
No, you can't deduce the "would be" orphans with pwg.categories.getImages, unless we add a new output field "categories_admin_list" which would not take permissions into account.
The pwg.categories.calculateOrphans method has been added by @MatthieuLP to make the computation as less often as possible, because it's an heavy one and it's useful only a very few times compared to the number of requests to pwg.categories.getImages.
pwg.categories.getOrphans
You mean pwg.images.getOrphans because if a photo is associate to a category then it can't be an orphan. So it would be mean "list of orphans if we delete this category" and it would be the exact same as pwg.categories.calculateOrphans. Please give me more details :-)
I understood that the pwg.categories.calculateOrphans method would return the "future orphans" of a user i.e. taking rights into account, but in fact it returns all future orphans on a server, which is the pwg.categories.getOrphans I was proposed. Fine with me.
> Warning: `pwg.images.getInfo` only returns the list of categories accessible to the current user. Not all categories. So you can absolutely not know if the photo would become orphan if you delete an album. Not reliable at all.
This is not reliable (incomplete) for an admin looking for orphans globally on a server, but this is perfectly fine for an admin or non-admin user managing his/her own photos i.e. for most usages. We miss a user status allowing to create/delete/move/etc. albums and upload/delete/edit photos/videos without access to server management tools.
> Currently, with `multiple_value_mode` in {append, replace} you should be able to associate/move/dissociate to albums. The limit is that you have to call `pwg.images.setInfo` for each photo. We've been discussing this topic with @remi-martin and he suggests we had a new method `pwg.images.setCategory` with 3 parameters :
>
> 1. image_ids (can be a list, that's the whole point)
> 2. action {associate, dissociate, move}
> 3. category_id
>
> I like this idea. Much more simple to associate/dissociate images to/from albums. We could also have a specific method for each action : `pwg.images.associateToCategory` + `pwg.images.dissociateFromCategory` + `pwg.images.moveToCategory` (or `pwg.images.category.associateTo` + `pwg.images.category.dissociateFrom` + `pwg.images.category.moveTo`)
Sure, a single call would be much more efficient. Similarly, I would welcome an update of the methods `pwg.users.favorites.add` and `pwg.users.favorites.remove` because we must call them repeatedly.
> > As for the proposed `pwg.categories.calculateOrphans` method, I do not believe
> > that we really need it because it would return an information we can deduce from
> > a call to the `pwg.categories.getImages`
>
> No, you can't deduce the "would be" orphans with `pwg.categories.getImages`, unless we add a new output field "categories_admin_list" which would not take permissions into account.
>
> The `pwg.categories.calculateOrphans` method has been added by @MatthieuLP to make the computation as less often as possible, because it's an heavy one and it's useful only a very few times compared to the number of requests to `pwg.categories.getImages`.
>
> > `pwg.categories.getOrphans`
>
> You mean `pwg.images.getOrphans` because if a photo is associate to a category then it can't be an orphan. So it would be mean "list of orphans if we delete this category" and it would be the exact same as `pwg.categories.calculateOrphans`. Please give me more details :-)
I understood that the `pwg.categories.calculateOrphans` method would return the "future orphans" of a user i.e. taking rights into account, but in fact it returns all future orphans on a server, which is the `pwg.categories.getOrphans` I was proposed. Fine with me.
<!-- github-comment-id:944472740 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
When you call pwg.categories.getImages for a category, all resources are returned with just a single category in their list of categories. This is regardless of how many they are linked to.
This is an issue if you then wish to unlink a resource(s) (e.g. image), because you do not know whether it will result in an orphan unless you first do a call to get the details of that/those image(s) pwg.images.getInfo. This is inefficient.
Given the api appears to return a list of categories, I'd expect it to do so. It seems pointless to just return the one that you requested the images list for using pwg.categories.getImages.
Hi,
I am wondering if it is possible to get several images from several albums (e.g 3 images from each of 5 categories) in one query? The way to do several requests for this task looks a bit ugly solution, and there is not much documentation on the API.
Your comment sounds interesting, but this should be raised as a separate issue. The issue I've raised is very different, referring to the list of linked albums returned for each resource when you retrieve the resources in a category.
Thanks for your attention. I found not much developers activity on this API, so decided to ask in a live thread close to the issue. Also posted this question to PIWI forum. Finally decided to query PIWI DB directly, this appeared to be the fastest and the simpliest method...
Sorry for off-topic message.
As discussed with @remi-martin yesterday we indeed have to fix this bug. But the result might not be what you expect. I explain. Currently
pwg.categories.getImagesreturns only one category (the current one, a bit useless, to say the least). I can work on it to fix it and provide the same list of categories as the one we see on the page of the photo (picture.php). That would not be the "full" list of albums. Indeed the photo can perfectly be linked to other albums but you don't see them because you don't have access to them.Reminder: even administrators are subject to the permission system.
In first conclusion: you won't be able to predict a photo would become orphan simply by relying on the list of albums returned by
pwg.categories.getImages(or bypwg.images.getInfoby the way). To do that, we could have a second list of "all categories", only provided when connected as administrator.Hello there, in piwigo 12 we plan to implement a method called pwg.categories.calculateOrphans, which as it names says, calculates and returns the orphans that would be created if you delete a category. I hope it will help you.
Thanks for looking into this issue.
Returning the list of categories to which the user has access would be what is expected and would avoid us to have to call the
pwg.images.getInfomethod repeatedly. From this data, we will be able to determine which images belong to which albums and which ones would become orphans if the user deletes an album (as seen by the user).pwg.images.setInfomethod withmultiple_value_mode=appendfor appending the category ID of the targeted album.multiple_value_mode=replacefor replacing the list of category IDs "belonging to the user". @plg, do you confirm that the method only replaces the list of albums to which the user has access (i.e. the lists provided bypwg.categories.getImagesandpwg.images.getInfo)?pwg.images.deletedoes the job.As for the proposed
pwg.categories.calculateOrphansmethod, I do not believe that we really need it because it would return an information we can deduce from a call to thepwg.categories.getImagesmethod without having to make an additional URL request draining the battery of a mobile (it would also be much faster).I would prefer a method
pwg.categories.getOrphanswhich returns the list of "true orphans" to admins in a format which can be used to display a virtual album of "true orphans" (output similar topwg.users.favorites.getList).Warning:
pwg.images.getInfoonly returns the list of categories accessible to the current user. Not all categories. So you can absolutely not know if the photo would become orphan if you delete an album. Not reliable at all.Currently, with
multiple_value_modein {append, replace} you should be able to associate/move/dissociate to albums. The limit is that you have to callpwg.images.setInfofor each photo. We've been discussing this topic with @remi-martin and he suggests we had a new methodpwg.images.setCategorywith 3 parameters :I like this idea. Much more simple to associate/dissociate images to/from albums. We could also have a specific method for each action :
pwg.images.associateToCategory+pwg.images.dissociateFromCategory+pwg.images.moveToCategory(orpwg.images.category.associateTo+pwg.images.category.dissociateFrom+pwg.images.category.moveTo)No, you can't deduce the "would be" orphans with
pwg.categories.getImages, unless we add a new output field "categories_admin_list" which would not take permissions into account.The
pwg.categories.calculateOrphansmethod has been added by @MatthieuLP to make the computation as less often as possible, because it's an heavy one and it's useful only a very few times compared to the number of requests topwg.categories.getImages.You mean
pwg.images.getOrphansbecause if a photo is associate to a category then it can't be an orphan. So it would be mean "list of orphans if we delete this category" and it would be the exact same aspwg.categories.calculateOrphans. Please give me more details :-)This is not reliable (incomplete) for an admin looking for orphans globally on a server, but this is perfectly fine for an admin or non-admin user managing his/her own photos i.e. for most usages. We miss a user status allowing to create/delete/move/etc. albums and upload/delete/edit photos/videos without access to server management tools.
Sure, a single call would be much more efficient. Similarly, I would welcome an update of the methods
pwg.users.favorites.addandpwg.users.favorites.removebecause we must call them repeatedly.I understood that the
pwg.categories.calculateOrphansmethod would return the "future orphans" of a user i.e. taking rights into account, but in fact it returns all future orphans on a server, which is thepwg.categories.getOrphansI was proposed. Fine with me.