Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1428048

    Hello,

    I’m wondering if there is a way to update all of the existing image content I used in my previous posts to a standard image size.

    Right now, when I open up an existing post and check the image sizing, it is set to ‘Theme Default is: Selected size from media library.’

    Is there a way to change this so all images in posts are set to Large? See private content section.

    Thanks!

    #1428054

    Hey kevinraposo7,

    Thank you for the inquiry.

    Would you mind providing a screenshot of the issue? You can use platforms like Savvyify, Imgur or Dropbox to upload and share the screenshot. Here are the steps to follow:

    1.) Visit the website of your chosen platform, such as Savvyify, Imgur or Dropbox.
    2.) Locate the option to upload a file or an image.
    3.) Select the screenshot file from your computer or device and upload it to the platform.
    4.) After the upload is complete, you will be provided with a shareable link or an embed code.
    5.) Copy the link or code and include it in your message or response to provide us with the screenshot.

    Thank you for taking the time to share the screenshot. It will help us better understand the issue you’re facing and provide appropriate assistance.

    Best regards,
    Ismael

    #1428140

    Hi Ismael,

    I’ve done one better – I attached a short screen recording which demonstrates exactly what I am referring to. Please see the ‘private content’ section, and let me know if you have any questions.

    Thank you!

    • This reply was modified 11 months, 2 weeks ago by kevinraposo7.
    #1428330

    Hi,
    Thank you for your patience and the video, I think I understand what you were hoping to do, but I couldn’t find a way to change this. But I did come up with a solution that may work for you. In your video I noticed that your example post was created with the ALB (Advanced Layout Builder) so I assume all of them are. So I created a couple of test posts, not pages, on my test site and added a couple of images with the Image element and one with the Text element, although I believe you are only using the Image elements.
    I set all of the images to medium size.
    Enfold_Support_4159.jpeg
    Then I used this function in my WPCode plugin as a PHP snippet, it will also work in your child theme functions.php:

    function adjust_image_attributes_for_single_posts($content) {
        if (is_singular() && in_the_loop() && is_main_query()) {
            $content = preg_replace_callback(
                '/<img(.*?)>/i',
                function ($matches) {
                    $new_img_tag = preg_replace('/width=".*?"/i', 'width="auto"', $matches[0]);
                    $new_img_tag = preg_replace('/height=".*?"/i', 'height="auto"', $new_img_tag);
                    $new_img_tag = preg_replace('/sizes=".*?"/i', 'sizes="(max-width: 1030px) 100vw, 1030px"', $new_img_tag);
                    $new_img_tag = preg_replace('/class=".*?size-medium.*?"/i', 'class="size-large"', $new_img_tag);
                    return $new_img_tag;
                },
                $content
            );
        }
        return $content;
    }
    add_filter('the_content', 'adjust_image_attributes_for_single_posts', 99);
    

    It replaces the image class size-medium with size-large, which is not important but I thought it may help with some related css, and it changes the image width & height attribute to auto and changes the size attribute to 1030px so the large image is used from the image srcset.
    This worked for me in ALB posts, I also tested in a Classic Editor post and it worked for the images in the post without changing the featured image, which is good because that is a different size and you would not want to change it.
    The only thing that I noticed was that on the Classic Editor post the images didn’t seem to change in size even though the source code changed, and this was because to container width of the post was narrow, when I added so css to make the container full width the images showed correctly.

    #top .fullsize .template-blog .post .entry-content-wrapper {
        max-width: 100%;
    }
    #top .fullsize .template-blog .post .entry-content-wrapper > * {
        max-width: 100%;
    }

    I don’t think this will matter for you, but I’m adding it for future readers that have this issue.
    So give this a try and see if it helps you.

    Best regards,
    Mike

    #1428435

    Hi Mike,

    That fix worked perfectly. Thank you so much for your help!

    #1428446

    Hi,

    Great, I’m glad that Mike could help you out. Please let us know if you should need any further help on the topic, or if we can close it.

    Best regards,
    Rikard

    #1428449

    You can close it.

    #1428463

    Hi,

    Great! Let us know if you have more questions about the theme.

    Have a nice day.

    Best regards,
    Ismael

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Standard Image Size’ is closed to new replies.