Skip Navigation

[Resolved] Creating image galleries for news from an old imported DB

This support ticket is created 2 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 2.24 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 6 replies, has 2 voices.

Last updated by Jamal 2 years, 11 months ago.

Assisted by: Jamal.

Author
Posts
#2048047

Hello
I have an old non-wp news site I have to recreate with Toolset. I already figured out how can I create a CSV from the old database and how to import it into WP and how to import RFGs too. The structure of the post is very simple: Title, Excerpt, Content, Date of Creation, Featured image, Image gallery.

I have problems with the image and gallery part. From the old DB I can obtain only the image name like: "image1.jpg". So I will have no media library in WP for the old posts. I will copy all the images into the /wp-content/uploads. In the old DB even if there is only one image, there is created a gallery, so I'll have to follow this approach too. I'll have galleries with only one and multiple images too. I will also have image descriptions at some images. I figured to create a RFG with a text field for the image name and another text field for the image description. I've not used the Blocks approach yet, I always used Views before. In view I could create a loop and in its template I could just add the custom field of the image's name. Can I do that with the Gallery Block too? Does my plan of creating the image gallery from the old DB sounds correct? After I import the old DB (7000+ posts) there will be new posts added regularly. That means that the gallery has to work for new posts too. Does this mean that I should add another image field too to the RFG and that would be used when the client will create new posts and add images from the WP Media Library?

Also related to the images problem is the problem of having a Featured image for the Posts. The old DB has no featured image in the DB. Can I add the first image in an RFG as Post Thumbnail if there is no Featured image selected (this is the case of the imported posts)?

Please assign somebody to my ticket who is close to my time zone GMT+2.

Thank you 🙂

#2048215

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting the Toolset support.

Images, and all media files, are managed by WordPress through a default post type(attachment) besides being uploaded to the /uploads/ folder.
The database entry for an image represents relevant data about it, such as the title, the description, the caption, the alt text, and any additional data through custom fields.
https://developer.wordpress.org/themes/basics/post-types/#attachment

I would recommend that you import the images through the CSV files too. Even if you will be copying them manually to the /uploads/ folder. WP All Import as an example offers a way to import image data without uploading files, allowing to copy the files manually. I am sure the importing plugin that you will be using offers such a feature.

This way, you can import the descriptions for the images, and have them generated in the galleries when using blocks. The blocks' galleries and Image sliders pull the description, title, alt text, and caption from the image post directly. They don't offer another dynamic way of retrieving it.

If you opt for this, you won't need to have a repeatable group to store the image and its description. So, you can use an image custom field that accepts multiple values in comparison to legacy views where you have more control.

Assigning the featured image directly to a post will require some custom coding. Depending on the implementation that you will opt for(Repeatable Field Group, or image field with multiple values, on save or on import), the custom code will be different. Let's discuss it once we get the galleries working.

I hope this helps. Let me know if you have any questions.

#2049937

Dear Jamal

Thank you your response. I still have some questions based on what you adviced me. It seems a good idea to import the images to the WP database. In the old DB I have the image name and a description field. Is this enough to import them? I though to change the WP settings to keep the images in a single folder and after an image optimization I would upload the files there. In this case I'll have the full image size in the database. Should I need to run a Regenerate thumbnails with a plugin like Smush? Or could it work with just the full image sizes? I have around 15.000+...

My other concern is that how can I link these imported images to the posts I'm importing. Is it enough to just create a repeatable image field and have the image name values in a single field/row separated by pipleline characters? How would this connect it with the attachment post?

I have WP All Import Pro, can that handle repeating image field? Because in case of RFG I was told that only Ultimate CSV Importer handles them and I should buy a license for that.

#2049939

Dear Jamal

Thank you for your response. I still have some questions based on your advices. Seems a good idea to import the database. I'll copy all the images in the uploads folder after an optimizations and I'll set WP to use only one folder. In this way I'll have the full size images in the new DB. After this should I make a regeneration of the thumbnails with a plugin like Smush? I have 15,000+ images so that might be an overkill... But will it work with only the full size image without thumbs?

My other concern is how I would link the images in the normal post import to the newly created attachment posts? Image name is enough for this? I'll have only the image names separated by pipeline characters in the repeatable image field cell. WP All Import is capable of importing repeatable images? In case of RFGs I was told that only Ultimate csv Import can handle them.

Sorry for writing the same reply twice, my browser showed me that the form was not submitted.

#2050279

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

I'll try to answer each of your questions below. Just keep in mind that WP All Import will also need the Toolset Addon https://toolset.com/course-lesson/import-posts-from-csv-with-relationships-using-wp-all-import/

My other concern is how I would link the images in the normal post import to the newly created attachment posts?
Let's say you are importing a custom post type "Products", by configuring the import of the images, WP All Import will create the "product" post and the related "attachment" posts. WP All Import can be configured to use images inside the server, which means that the upload will not be done, but the related "attachment" post will be created.
hidden link

Is it enough to just create a repeatable image field and have the image name values in a single field/row separated by pipleline characters? How would this connect it with the attachment post?
First, you need to create the image field in Toolset. Then, in the import, I think that you can use the pipe separator. Honestly, I never tried it.
Otherwise, you should probably use the FOREACH loop from WP All Import. Because Toolset saves a new entry in the metadata table for each instance of the field.
hidden link

You won't need to link the attachment posts to their parent posts, WP All Import will do it.

Should I need to run a Regenerate thumbnails with a plugin like Smush? Or could it work with just the full image sizes?
Toolset should work with the full image sizes. When a custom image size is used somewhere, Toolset will regenerate the resized image.
Resizing images using Smush will generate the sizes registered in WordPress(from theme, and plugins(woocommerce for example)). Toolset won't need to regenerate registered sizes, but it will still need to regenerate a custom size upon request. Once a custom-sized image is generated it will be reused in subsequent requests.

I hope this answers your questions. Let me know if you have any further questions.

#2050333

I don't really understand how the linking could work so I'll try to break down in steps for myself what I understand.
Before these stept of course I already create the CPT and the custom fields, like the repeating image field.

Step 1 - Creating a CSV for image library: two columns, one for the image name and one for the image description. I'll import that with the import plugin for attachment post type.

Step 2 - Creating the CSV for the news article posts: in this CSV I'll have a column for image gallery (corresponding to the repeatable image field in toolset). An image gallery cell contains all images for that gallery separated by the pipe char like: image1.jpg|image2.jpg|image3.jpg. When I import this CSV, the import pluging can link every image to the corresponding attachment post by the filename?

I'm not sure I'll use WP all import pro. I've read in many places here the the Ultimate CSV importer works better with toolset.

#2050517

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Well, I can't really say if Ultimate CSV importer works better than WP All Import or the opposite. As a matter of fact, we don't provide support for any of them. We still help our users to use them, but when it comes to updates and bug fixing, the plugins' authors who support their own plugins.

You won't need two steps to import, you can perform it in one step with one CSV file, the posts CSV file. Add one column for the image names and one for the image descriptions. Then configure the image path and description in the import configuration.
hidden link

I am quoting the WP All Import documentation below hidden link

Image meta data can be imported in the SEO & Advanced Options sub-section of the Images section in WP All Import.

Meta data will be associated with images based on the order of the images and order of the meta data – for example, the first caption will be associated with the first image, the second caption will be associated with the second image, and so on.

I would suggest that you try on a test install with a couple of posts and their images. Once you can confirm everything works as expected, you can perform a full import and validate if everything is as expected.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.