Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator bcworkz

    (@bcworkz)

    I cannot replicate the same behavior on my site using the 2024 theme and no plugins. There’s something odd about your particular site.

    It’s difficult to decipher the error messages because all of the JS files are minified. Try adding this to wp-config.php:
    define( 'SCRIPT_DEBUG', true );
    This will cause the non-minified versions to be used, making it easier to understand what code is causing the problem.

    Apparently something has become corrupted somewhere. Could be the gallery, the image meta data, or WP files themselves. Corrupted WP files are the easiest to resolve, believe it or not. You could perform a manual update, even if it’s to the same version. The point is to replace your current files with those from a fresh download. Resolving corruption in your DB is not so simple I’m afraid.

    Thread Starter aljoersz

    (@aljoersz)

    Thank you for your response! It appears to be some issue with the block editor. I’m not sure if it’s tied to my hosting platform or is more widespread but I had the same error when attempting the same action on a completely different website. I’m told I have to wait for a WP update/fix but in the meantime, will have to use a different editor (Elementor was recommended).

    Moderator bcworkz

    (@bcworkz)

    Elementor is very popular. The one issue you should consider with it is once you’ve used it to create a page’s content, you’re pretty much committed to using Elementor to edit and view that page going forward. If you’re OK with that, it’s a reasonable solution.

    If I understand your situation, you can save edited posts or pages OK, it’s attempting to edit existing galleries that’s the problem. I thus imagine there’s an issue with media library scripts somewhere. I do have one idea for a possible workaround using the block editor. It does require that you directly edit HTML code. It’s not as bad as it may sound because you have existing gallery code as a guide. I recommend using the code editor view (from 3 dot icon drop down) to insert you desired images. (or remove others if you so choose).

    Find the gallery’s HTML comment, it starts with <!-- wp:gallery. Also locate its corresponding closing tag: <!-- /wp:gallery --> In between are the image blocks consisting of figure and img tags and optionally an anchor (link) tag. They are demarcated by wp:image comments similar to the wp:gallery comments. You can copy/paste one of the wp:image blocks and replace the existing image and anchor URLs with those for a new image.

    Beware that there might be figcaption tag just before the closing /wp:gallery tag, outside of any wp:image block. It’s for the gallery’s caption. Do not insert more wp:image blocks below this. There will also be the image attachment’s ID occurring in a couple places. These will need to be updated to the new image’s ID. You can get the correct ID from the image’s edit link in the media library. The link URL will be something like: wp-admin/post.php?post=1234&action=edit In this example the image’s ID is 1234.

    I recommend keeping the media library open in another browser tab so you’re able to collect necessary image data without needing to save/close the code editor.

    I’m sure this all sounds horribly fussy and complicated. It really isn’t, it’s just difficult to describe in words. You already have wp:image blocks you can use as a guide, it’s only a matter of updating certain image specifics in the copied block.

    Thread Starter aljoersz

    (@aljoersz)

    Yes, that’s actually more or less what I ended up doing yesterday (before reading your response). I played around with Elementor and I found the free version too limited (I couldn’t assign links to individual photos in the gallery). It also wouldn’t let me convert an existing page with gallery without a whole heck of a lot of work (reinserting all the photos, etc). I have very little if no knowledge of coding but somehow I was able to do essentially what you suggest. I used classic editor to insert new photos into the gallery and edited the code, copying and pasting prior photo code but inserting the new photo copied link from media files, updating the image ID, and inserting the new external link for that photo. Since I don’t understand all that goes into every line of code, I had quite a bit of trial and error to get it right but ultimately it worked.

    What I found I had to do, however, is once everything was set with classic editor, I had to go back to the page afterwards with the block editor because there were always some errors (although I’m not sure what they were exactly). When I went to the page through block editor, it gave me an error with a button to “recover block” (or some wording to that effect). When I clicked on the recover button, it easily corrected whatever error I had made and everything was fine. So basically, I was just going back and forth between classic and block editors to get things set right since classic is the only way to insert photos and block is the only way to get the coding correct. It’s definitely clunky but I’m glad there’s a manageable workaround that won’t require me to re-do all my photo galleries. Thanks again!

    Thread Starter aljoersz

    (@aljoersz)

    One thing I forgot to add: This is not just happening when I go to insert a photo in an existing gallery. It’s also with new galleries on the same page and new galleries on new pages. And then also, new pages with new galleries on completely different websites. So I don’t know think there’s some kind of underlying error in my website but perhaps it’s a problem on the hosting site and a wordpress update? I don’t know exactly when the problem started happening since I put off dealing with it for several months but I believe it started happening sometime in October.

    I’m inclined to leave this as unresolved status in case other people have the same issue and want to chime in? At this point, it doesn’t seem like anyone else is having the same problem.

    Moderator bcworkz

    (@bcworkz)

    Sadly, manually editing gallery code is far more tedious than using the intended UI. But at least it’s sort of a solution. And you’ve probably picked up some additional HTML coding knowledge. It could be useful knowledge to have some time in the future.

    All I can say is I’m not having any trouble using galleries on my site and I’ve not seen any related topics in the forums from others with a similar issue. So the issue is likely something about your sites. It could be a problematic plugin or something about your server or hosting configuration.

    This topic may be left open in case anyone else has anything to add. TBH, once a topic has started a reply thread, a lot of non-participants stop reading. There’s always a chance someone could land here via search who has a similar problem. They would be more likely to read and add a comment.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘“unexpected error” inserting photos into gallery’ is closed to new replies.