• alexom2

    (@alexom2)


    Hello,

    I have a BUNCH of galleries that I need to re-create (because the old code of the galleries has not managed to be updated to the new ones).

    So I would like to be able to search for multiple images at once, instead of searching and adding each image, one after the other one.

    For instance, I would like to search for: “image-a.jpg, photo-2.jpg”.
    I have not found any plugin to do that.

    I tried to make one with chat get…but it failed.
    Would it be a way to add a piece of code to make it work?

Viewing 5 replies - 1 through 5 (of 5 total)
  • threadi

    (@threadi)

    I’m not quite sure what kind of search you mean. I assume that you are talking about the assignment of images to the new gallery? Then you have an “Add” button on the new gallery and after clicking on it you can only search for & add a single image?

    To answer that, you would need to know which gallery you are using. Depending on this, we could tell you whether it is possible to search for and select several images at the same time instead of a single selection. However, it might make more sense to contact the support of the gallery plugin you are using directly.

    Moderator bcworkz

    (@bcworkz)

    I’m guessing you wish to re-create the exact same galleries using a newer gallery block or plugin. IMO, the best approach would be for each old gallery, extract which images are used and use that data to create a new gallery. This would very likely be a custom coded solution, but once the code is working, it would require very little manual intervention to re-create many dozens of galleries. You would need to know how both gallery types manage which images are in each gallery.

    Even if you do not wish to exactly recreate each gallery, it still could be beneficial to do so as a starting point, then further modifying them as needed.

    If there are other supporting data such as captions, those could be migrated as well if how they are managed is known. Sometimes all of this can be deduced by directly examining DB content through an app like phpMyAdmin. Failing that, seek the advice of the respective gallery developers like threadi suggested.

    Thread Starter alexom2

    (@alexom2)

    Hi @threadi & @bcworkz

    Thanks for your messages.

    You get it right,

    I am looking to re-create new galleries using the native galleries from WP.
    (the actual galleries are using an old code that can’t be converted into new code. So, it is easier to create new galleries (with new gallery block) using the same images).

    @bcworkz
    I have found a solution to get the list of the images in each gallery. I copy the HTML code (of the published page) of each gallery, give it to Chat GPT, and ask it to extract the list of all the .jpg it found).

    Then,
    I go to the visual editor, click on add a block, select the gallery block, and then click on “media library” to look for images. Then, at the top right, there is a search box that allows me to search for images.
    The limitation of this box is that I can search only one image at a time…so it takes forever.

    Therefore, I would like to search for multiple images at once, instead of one by one.
    So, yes, I figure that I would need a custom code to allow that…. Except if there is a plugin that can do it?

    threadi

    (@threadi)

    Theoretically, you would have to generate the HTML code for a gallery block. This is what the block editor uses to display a gallery.

    Here is a pseudo example:

    <!-- wp:gallery {"linkTo": "none"} -->
    <figure class="wp-block-gallery has-nested-images columns-default is-cropped"><!-- wp:image {"id":42, "sizeSlug": "large", "linkDestination": "none"} -->
    img-element
    <!-- /wp:image -->
    
    <!-- wp:image {"id":43, "sizeSlug": "large", "linkDestination": "none"} -->
    img-element
    <!-- /wp:image --></figure>
    <!-- /wp:gallery -->

    I would generate something like this using a PHP script. You could give it the original code and let it generate this. Requires some PHP knowledge of course, but it could be done.

    Unfortunately, I don’t know what the original code looks like, which is why I can’t describe a more precise procedure here.

    If you need help with this, you can find someone here: https://jobs.wordpress.net/

    Moderator bcworkz

    (@bcworkz)

    If your old galleries use the classic editor’s [gallery] shortcode, the images for the gallery are saved as the (attachment) ids attribute value, like this:
    [gallery ids="988,917,862,957"]

    A custom script could do a search query for all posts with this shortcode in post content. For each post found, extract the gallery shortcode’s ids attribute values. Use the IDs to get the related image HTML and construct a valid gallery block. Use the gallery block to replace the old gallery shortcode. Or better yet, make the shortcode into a HTML comment as a sort of backup. Insert the new gallery block immediately afterward.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘search multiple images at once’ is closed to new replies.