Skip to content

Relative image src URLs show as broken images in search results #975

@siracusa

Description

@siracusa

When Pagefind extracts the src=… value from an <img> tag for use as the thumbnail image in the search results list, it is shown as a broken (i.e., missing) image if the src=… value in the indexed page was a relative URL.

For example, consider a website with a Pagefind search form located at /search and an indexed page located at /blog/about.html. At the top of the /blog/about.html page is an image tag like this:

<img src="images/header.png" …>

When that page appears in the search results on the /search page, Pagefind will show a thumbnail img tag with src="images/header.png". That image will appear broken on the search results page, since the search page is located at /search and the indexed page was located at /blog/about.html. The images/header.png image source is relative to the index page's location in /about and not the search page's location of /search.

Pagefind should convert relative image source URLs into absolute image source URLs by prefixing them with the location of the indexed page. In this case, it should prepend /about/ to the image source images/header.png to form /about/images/header.png, then use that as the image source for the thumbnail on the search results page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions