• Resolved henry88g

    (@henry88g)


    Using WordPress 6.1.1 and Simple Lightbox 2.9.3, all is ok when image <a href=”absolute URL”> but fails with relative URL. I hope it’s just because I’m not specifying the relative URL properly. Can someone help? I do wish to use relative URLs.

    I can use relative URLs in the <img src=””> tag, and also in the <a href=””> tag if the target is not an image file (works with .txt file, for example) – so it appears that the plugin catches references to image files, but not with the relative URLs in the form I’m using.

    Typical image code with absolute URL is

    <!-- wp:image {"id":131,"width":768,"height":537,"sizeSlug":"large","linkDestination":"custom"} -->
    <figure class="wp-block-image size-large is-resized"><a ><img src="../wp-content/uploads/2023/01/Suns-refrain-Series-of-5-No-1.edit2_-1024x716.jpg" alt="Suns-refrain" class="wp-image-131" width="768" height="537"/></a><figcaption class="wp-element-caption">Suns-refrain-Series-of-5-No-1.edit2</figcaption></figure>
    <!-- /wp:image -->

    Typical image code with relative URL (image shows ok, but no lightbox popout)

    <!-- wp:image {"id":131,"width":768,"height":537,"sizeSlug":"large","linkDestination":"custom"} -->
    <figure class="wp-block-image size-large is-resized"><a href="../wp-content/uploads/2023/01/Suns-refrain-Series-of-5-No-1.edit2_-1024x716.jpg"><img src="../wp-content/uploads/2023/01/Suns-refrain-Series-of-5-No-1.edit2_-1024x716.jpg" alt="Suns-refrain" class="wp-image-131" width="768" height="537"/></a><figcaption class="wp-element-caption">Suns-refrain-Series-of-5-No-1.edit2</figcaption></figure>
    <!-- /wp:image -->

    <a href=”../wp-content/uploads/2023/01/xxx.txt> displays the file ok.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Archetyped

    (@archetyped)

    Relative URLs are supported as long as WordPress itself can resolve them (SLB uses WordPress’ built-in functionality).

    The link provided did not contain any image links with relative URLs. Please provide a link to a page that contains image links with relative URLs and I would be glad to take another look.

    That said, using site-root relative URLs (/wp-content/uploads/image.jpg) is highly recommended over path-traversing relative URLs <meta http-equiv=”content-type” content=”text/html; charset=utf-8″></meta>(../wp-content/uploads/image.jpg), as they are less fragile and will work on any page on the site. By contrast, path-traversing relative URLs resolve differently depending on the URL of the page they are posted on.

    For example, given the relative URL: <meta http-equiv=”content-type” content=”text/html; charset=utf-8″></meta>../wp-content/uploads/image.jpg used on the following URLs:

    • https://domain.com/post-name/ Resolves to: https://domain.com/wp-content/uploads/image.jpg
    • https://domain.com/archives/123/ Resolves to: https://domain.com/archives/wp-content/uploads/image.jpg

    Using a site-root relative URL would resolve to the same URL on either page.

    Thread Starter henry88g

    (@henry88g)

    Thanks very much for swift response. All good. I don’t know just where I went wrong, but everything is fine using site-relative URLs. I thought I had done so at one time, but perhaps it was too late at night.

    Plugin Author Archetyped

    (@archetyped)

    Glad to hear your issue is resolved ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Relative URLs’ is closed to new replies.