Sync LR custom ordering with RML
-
The integration of WP/LR Sync with Real Media Library allows for galleries to be updated to posts without having to change the array of ids in the shortcode in the posts. However, the default ordering of photos in RML galleries managed by WP/LR Sync does not respect the custom ordering set in Lightroom. Since WP/LR supports custom ordering for the Post Types extension, can the support be extended to the RML extension as well?
-
Hi,
You could ask Matthias, the developer of RML, to come on this thread and to tell us if it’s possible to reorder the images within a collection in RML, through its API. Then we can discuss it more ??
Alternative solution: did you try to use directly the WP/LR Sync gallery shortcode? Then it will work right away ??
Thanks for the reply. Meanwhile I’ll check out the WP/LR Sync gallery shortcode. However, the Post Types extension automatically generates pages with [gallery ids="..."] shortcode.
Yes, the extension also generates it. I like it this way because it’s a good test also about how my API performs ?? But if you want to do it by yourself, the shortcode is the best, and it keeps everything very simple.
I am also working on a block for Gutenberg (the new editor that will be the new default one in WordPress 5).
This turned up after a brief search. Relevant?
https://matthias-web.com/docs/real-media-library/php/class-MatthiasWeb.RealMediaLibrary.api.IFolderContent.html#_contentOrderHi there,
Here is the developer of Real Media Library, thanks for your interest in both plugins. ??
There are a few feature requets for WP/LR + Real Media Library. I have tried to extend the extension to allow an image to be placed in multiple folders but the trial of Adobe Lightroom was too short for this. I have contacted Adobe for a developer license for but unfortunely they do not provide something like this. I have to contact them again… perhaps there is another way.
I will also add this feature (custom order) to my todo list but I can not tell you an exact ETA for this.
@tigroumeow How is the order saved in WP/LR? Real Media Library uses a “order” column for each attachment to create custom orders. I think about a way to map the “order” column to the WP/LR order via SQL query, you know what I mean?
Best regards,
Matthew ??Hi @mguenter,
Would be good to find a common user of both of our plugins who is a developer as well… and this user could also develop the extension. For me, it is very hard to support all the themes and plugin out there so that’s why I worked hard on making this API perfect, with a few examples (and it worked, because you could actually develop the current for RML perfectly).
I also still think RML shouldn’t actually work through a WP/LR Sync extension, and just get the data directly from WP/LR Sync, through two functions (basically getHierarchy and getGallery). By doing that, the order would be also taken in account. And for somebody who just install RML, or WP/LR Sync, without resyncing the extension it would work right away. Just an idea but I think it would be great to do it directly like this ??
Of course there is also the information directly accessible in the database (in the lrsync_relations, that links the photos to the galleries, for each of those relations there is also the order, the ‘sort’ column), and there is a action/filter for it available for the extensions.
@tigroumeow, would it be possible to make a rather inefficient set of calls through wp_attachment_order_update (https://matthias-web.com/docs/real-media-library/php/function-wp_attachment_order_update.html) to order the collection? Then a resync with the extension will produce the correct order within RML. Thanks for looking into this.
Actually, what WP/LR Sync does currently is that it calls the action to remove all the medias from the collection, then it calls the actions to add the medias in the right order. So basically, your RML collections/folders/galleries get emptied every time there is a re-order, and the images re-added to them. Now, the thing is maybe RML does its ordering not based on the order of those actions, but on something else.
You could try to play with this wp_attachment_order_update function in the real_media_library.php extension in WP/LR Sync, especially in the add_media_to_collection function. Maybe just calling the RML function there, with the right arguments (the default one?) will make the trick. Matthias can confirm this I think.
Hi @tigroumeow, @winstonyin,
The Real Media Library extension for WP/LR simply moves the file from ” /Unorganized” to the given WP/LR collection/gallery. I have another idea… I think Real Media Library does not respect the custom order because the folder content is loaded by default date descending. The solution would be to set the RML collection/gallery to custom order. When WP/LR now syncs the files the order is respected and each new image is put to the top of the content:
The function to enable custom order for a folder:
https://matthias-web.com/docs/real-media-library/php/class-MatthiasWeb.RealMediaLibrary.api.IFolderContent.html#_contentEnableOrderHere you can find the modified extensions/real-media-library.php file:
https://gist.github.com/matzeeable/3da02949936540c6be3966df7e975b70Jordy, do you provide a hook when a single collection/gallery is finished with reordering the content? The above solution sets the order reversed because the first image is always put to top – so the order has to be reversed in the database table of RML. Please let me know so I can provide a SQL query.
Unfortunely I can not test this because my trial in LightRoom expired and no longer works. ??
Regards,
Matthew ??-
This reply was modified 7 years, 1 month ago by
Matthias Günter.
@mguenter, thanks for the suggestion. With your modified real-media-library.php, I added another line in add_media_to_collection to move each newly added attachment to the end of the collection:
wp_attachment_order_update($id, $mediaId, false);
This results in the correct order in RML, but only for those WPLR collection that have custom order. For WPLR collections without custom order (e.g. sorted by capture time in LR), the attachment order is completely messed up.@tigroumeow, it appears that LR collections sorted by capture time (default) do not trigger the order_collection function when published. Since WPLR must assume some default order anyway, is it possible to treat capture time ordering as a “custom order” as well, and increment the “sort” column in wp_lrsync_relations table? This, in addition to the above changes, should solve the current issue.
Hi all,
The order_collection is only triggered when LR has an ‘custom order’ event, otherwise, there is no ordering or re-ordering, and the new images are simply added, without any order. I have thought about it, and the plugin could re-order by itself on every upload, but I am not sure what the result would be of this, and the plugin shouldn’t assume that the calls are in the wrong order and to force order by date. Right now the DB is clean from that point of view.
Should we host the extension somewhere special? Should I create a GitHub repo for it, and I will keep the extension in the plugin updated for it? Should I start from https://gist.github.com/matzeeable/3da02949936540c6be3966df7e975b70 ?
I could add an action that set the Custom Order on a collection. If that happens, then the extension could indeed do the “wp_rml_get_object_by_id($id)->contentEnableOrder();”. Otherwise, it wouldn’t. That would work @mguenter, right?
Hi again,
This results in the correct order in RML, but only for those WPLR collection that have custom order. For WPLR collections without custom order (e.g. sorted by capture time in LR), the attachment order is completely messed up.
Can you perhaps share the code with us (create GitHub gist)? Perhaps you are also interested in extending the extension for RML + WP/LR? ??
@tigroumeow
Yeah, please create a GitHub repository so I can fork from it and send pull requests if needed. ?? … Or is it possible to set two GitHub owners? And yes, you can take the Gist but perhaps you can wait for @winstonyin answer because he has modified it a bit.I could add an action that set the Custom Order on a collection. If that happens, then the extension could indeed do the “wp_rml_get_object_by_id($id)->contentEnableOrder();”. Otherwise, it wouldn’t.
When is this action called? The
contentEnableOrder()
method must be called before adding new images otherwise thenr
column in database becomesnull
for all new files.Hello guys,
Sorry, I don’t have much time these days, too much work ?? But I really wanted to create this repo with a bit of information, and start link to it from my website. Here it is: https://github.com/jordymeow/wplr-sync-extensions. I will keep the extensions updated from there ?? You are welcome to send pull requests too.
-
This reply was modified 7 years, 1 month ago by
- The topic ‘Sync LR custom ordering with RML’ is closed to new replies.