OK so… literally just about to launch a new site (with existing members/images/galleries) and I’m so fed up with rtMedia that I’ve decided to bite the bullet and convert to Mediapress before I do.
I note you’re still working on an import/conversion between the two, so please forgive me for asking a question you’ve probably been asked a hundred times before, but do you have any pointers (or even any half-finished code) that might point me in the right direction?
I’m more than happy tinkering with the database (as far as I can tell so far, looks as if Mediapress just needs a post for each gallery and attachments for each image?) but I suspect it’s the postmeta that may trip me up (particularly the serialized data)… I’m guessing they’re all essential for Mediapress to work correctly?
I’ve also worked wonders with WP All Import before, if/when I can get the settings right but it seems to be getting confused over whether the images are attachments or images (or that could be me… it’s getting late here). And again, it’s the postmeta that I have a feeling is going to be the hardest part to get right (though I guess I could add later if necessary).
The support here seems so much better than anywhere else and having tested Mediapress over the last few days, I’m absolutely sold… if I can only manage to convert the data in time! As mentioned above, any/all suggestions/pointers would be hugely welcome, or indeed, if you have something half-developed and would like an eager tester, even better.
With many thanks in advance.
Hi NikB,
Thank you for posting.While moving from RTMedia to MediaPress, we will most probably need to account for
1. Moving gallery
2. Moving Media
3. Moving activityIn last few releases, I have been adding functionalities in MediaPress to make the migration/importing from any
In order to the above tasks, we need to know about the rtMedia and its architecture.
For MediaPress, if you plan to write a migrator in PHP, here is how it should be
1. Make sure you have both the plugins active.
2. Find All RT Media Galleries(do they support media without gallery too?) by code.3. For each gallery, find the title, slug, privacy, type, owner user and if it is group or user gallery.
Use mpp_create_gallery() to create MediaPress gallery.
Possible values for component=’members’ and ‘groups’ and the component_id will be the member id or the group id based on the component.Now, for the created gallery, find each media from related RT media gallery and use mpp_import_file() or mpp_import_attachment() for importing file or (WordPress attachment to MediaPress gallery)
Repeat the process for each gallery.
PS:- Moving activity will be a bit complex.
To be honest, if you have a site with RTmedia, I will suggest to stick with it if you are going live soon.
Creating and migrating from RtMedia to MediaPress will be a major task and it might not suit for the project.
For references:-
https://buddydev.com/mediapress/guides/api-reference/media/For mpp_create_gallery https://buddydev.com/support/forums/topic/help-w-auto-create-gallery-code/#post-14752 should act as an example.
Regards
BrajeshThank you so much for such a quick reply.
A few quick comments in return…
I am not so bothered about activity as users have been told it’s a new site but their existing galleries will be imported, so activity can start afresh once the site goes live.
rtMedia creates a post in wp_posts for each album/gallery (ie. post type ‘rtmedia_album’) and a post for each image in wp_posts (ie. post type ‘attachment’ with the parent_ID set to the album/gallery post). In that sense, from what I understand it’s fairly similar to Mediapress.
Somewhat confusingly, rtMedia then goes on to add entries in a separate table (wp_rt_rtm_media) for each album/gallery and for each photo but I think/hope I can actually ignore this and get all the information I need from the wp_posts table.
I’ve only just had a quick look at the examples you’ve given, but if I’m understanding correctly, I’d somehow need to create a query which generates all the necessary galleries and then somehow loop through the function mpp_create_gallery() for each one, then do the same for the media (in my case, it’s just images) using either mpp_import_file() or mpp_import_attachment() ?
As far as the metadata goes… from my tests it would appear that these are as follows –
Galleries –
_mpp_media_count
_mpp_cover_id
_mpp_component_idAre all of these essential or can the first 2 be added later? Or perhaps the function you have given will automatically do this?
Images –
_wp_attached_file
_mpp_component_id
_mpp_is_mpp_media
_wp_attachment_metadataAgain will the function you have given add these automatically? I’m guessing WordPress will generate the first and last?
Hope this makes sense and thank you again. I really do appreciate your help.
Warm regards
NikPS. If it makes any difference, all the image files are already stored in the uploads folder under uploads/rtmedia/users/userid/year/month but of course, I can always move them manually if necessary.
Hi Brajesh
Thanks to your helpful hints… I did it! I’m still fairly new to writing my own PHP, so there is probably a more elegant way of doing this, but in case it’s any help, here’s the code I used…
function my_update_posts() { $args = array( 'post_type' => 'rtmedia_album', 'numberposts' => -1 ); $myposts = get_posts($args); foreach ($myposts as $mypost){ if ( ! function_exists( 'mpp_is_user_gallery_component' ) ) { return; } $gallery_id = mpp_create_gallery( array( 'creator_id' => $mypost->post_author, 'title' => $mypost->post_title, 'description' => '', 'status' => 'public', 'component' => 'members', 'component_id' => $mypost->post_author, 'type' => 'photo', 'date_created' => $mypost->post_date, 'date_updated' => $mypost->post_modified ) ); if ( $gallery_id ) { mpp_update_wall_gallery_id( array( 'component' => 'members', 'component_id' => $mypost->post_author, 'media_type' => 'photo', 'gallery_id' => $gallery_id ) ); } $args2 = array( 'post_type' => 'attachment', 'post_parent' => $mypost->ID, 'numberposts' => -1 ); $myposts2 = get_posts($args2); foreach ($myposts2 as $mypost2){ mpp_import_attachment( $mypost2->ID, $gallery_id); } } }
Important notes to anyone thinking of trying this…
Back up your database (and image files) first! You can only run this code once – if it goes wrong, the references to rtMedia_albums will have gone/attachments will have moved, and you’ll need to start afresh.
I’d hoped that adding date_created and date_updated to the code would mean the galleries/albums would retain the dates when they were originally uploaded but this didn’t seem to work. Possibly there’s a fault in my code somewhere but I’m just happy that it worked as well as it did!
It’s not fast… I had about 10,000 images and it took about an hour to run… then again, it’s not that slow either 😉
Hope this might be of some help to someone, especially if you can write neater code.
Warm regards
NikPS. Now… if I can just figure out why comments on photos keep disappearing (see my other post), I’ll be a happy girl!
Hi Nik,
Congratulations 🙂Yes, your code is nice but I would have probably used chunking and some feedback. Still, I had no idea that RT Media started using post type for gallery. It’s good to know and will help us when we provide a migrator.
Thank you for sharing .
PS:- Anyone planning to use the code, please do note that all the galleries here are marked ‘public’. Also, you will need to change the script time by using
set_time_limit(0); before the code.Regards
BrajeshHi Brajesh
Yes my code was definitely just a quick and dirty version for my own purposes but I’d be pleased if the general concept was some help.
And yes… I also found it strange that RTMedia seems to use both wp_posts and its own separate table in the database too, perhaps one is a legacy of the other? I think I’m right in saying that if you wanted to import views/specify privacy etc, that would need to come from the RTMedia table but for my purposes, the information in the wp_posts table was enough.
If you’d like any further info, please do let me know. It’s the least I can do in return for such great support.
Regards
NikHi Nik,
Thank you.I certainly believe that you sharing code was very helpful. I haven’t checked RT Media’s code/architecture in recent past, so I was not aware.
It will help us when I or my team writ a migrator and when we do, if we ever get into trouble with there architecture, I will be getting in touch with you for the guidance.
Thank you again.
Brajesh
As mentioned above, you are more than welcome to get in touch @Brajesh 😉
Although I have now successfully switched to Mediapress on the particular site I was working on, I have kept a backup copy prior to conversion, so could always use that to test any code you come up with.
I’ll mark this as resolved now but feel free to contact me any time.
Warm regards
Nikki
The topic ‘ [Resolved] rtMedia to Mediapress’ is closed to new replies.