Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1368070

    Hello everybody
    I have a question
    have created a page name below:
    on the page 1Link below:
    The image in the first place is the image in the Media Library
    stored under this path 2Link below:.
    I want to change the pad but this image I want to use is not in the Media Library but 3Link below:

    is this possible

    thanks in advance
    kind regards
    Franz

    #1368082

    Hey schweg33,
    Thanks for the link to your page, you can use javascript to replace the image and link of the image element image.
    Try adding this code to the end of your functions.php file in Appearance ▸ Editor:

    function custom_replace_image_in_image_element() { ?>
      <script>
    window.addEventListener('DOMContentLoaded', function() {
    var image = document.querySelector("#top.postid-142 .avia-image-container.avia-builder-el-8 img");
    var link = document.querySelector("#top.postid-142 .avia-image-container.avia-builder-el-8 a");
    var source = "https://-your-domain-/wp-content/uploads/fruher-und-heute/Restaurant-Fernsicht-1966.jpg";
    image.src = source
    image.srcset = source
    link.href = source
    });
    </script>
      <?php
    }
    add_action('wp_footer', 'custom_replace_image_in_image_element');

    Ensure that you fix the url to the image before testing, I was not sure if you wanted it posted.
    You may want to resize your image to the size you wish, currently it is a different aspect so making it fit with css will stretch it.

    Best regards,
    Mike

    #1368167

    Hello Mike
    Thank you very much that worked great.
    Great support thanks.

    What do I have to do if I want to change two images on one page.
    top.postid-142 that is clear to me
    if I want to change two images.
    (there are then only two on the page, left and right)
    how do I have to specify.

    thank you
    kind regards
    Franz

    #1368171

    Hi,
    Glad to hear, for two images you need to specify the two images, the first image container was .avia-image-container.avia-builder-el-8 img the second one is .avia-image-container.avia-builder-el-10 img so to add both to the same script it would look like this:

    function custom_replace_images_in_image_element() { ?>
      <script>
    window.addEventListener('DOMContentLoaded', function() {
    var image1 = document.querySelector("#top.postid-142 .avia-image-container.avia-builder-el-8 img");
    var link1 = document.querySelector("#top.postid-142 .avia-image-container.avia-builder-el-8 a");
    var source1 = ("https://archiv.dorfgeschichte.li/wp-content/uploads/fruher-und-heute/Restaurant-Fernsicht-1966.jpg");
    var image2 = document.querySelector("#top.postid-142 .avia-image-container.avia-builder-el-10 img");
    var link2 = document.querySelector("#top.postid-142 .avia-image-container.avia-builder-el-10 a");
    var source2 = ("https://archiv.dorfgeschichte.li/wp-content/uploads/fruher-und-heute/Restaurant-Fernsicht-1966.jpg");
    image1.src = source1
    image1.srcset = source1
    link1.href = source1
    image2.src = source2
    image2.srcset = source2
    link2.href = source2
    });
    </script>
      <?php
    }
    add_action('wp_footer', 'custom_replace_images_in_image_element');

    but I see your test page has changed so I don’t know if we are talking about the big images or the thumbnails, but as long as you specify the image containers this should work.

    Best regards,
    Mike

    #1368174

    Thank you Mike
    Looks very good

    You can close this request then

    kind regards
    Franz

    #1368179

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Replace path only’ is closed to new replies.