htmlimages

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package htmlimages rewrites <img> tags in HTML content into resized-preview links (with PhotoSwipe captions), using an imagestyle.ResizeService.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentProcessor

type ContentProcessor struct {
	// contains filtered or unexported fields
}

ContentProcessor rewrites content images into preview links.

func NewContentProcessor

func NewContentProcessor(resizeService *imagestyle.ResizeService) *ContentProcessor

NewContentProcessor - a ContentProcessor making the previews with resizeService.

func (*ContentProcessor) Forget

func (cp *ContentProcessor) Forget()

Forget drops the rewritten texts kept: the previews they link to were deleted.

func (*ContentProcessor) ProcessImages

func (cp *ContentProcessor) ProcessImages(htmlContent string) string

ProcessImages replaces local <img> tags in htmlContent with resized previews wrapped in PhotoSwipe links. Unparseable HTML is returned as is. The result is kept for the same text, unless an image of it failed (its store unreachable, say: the next view tries again).

func (*ContentProcessor) SetLightbox

func (cp *ContentProcessor) SetLightbox(fn LightboxFunc)

SetLightbox makes the links open what fn gives of an original (a large copy of it) instead of the original. Set it before the first text is rewritten.

type LightboxFunc

type LightboxFunc func(src string, width, height int) (url string, w, h int, ok bool)

LightboxFunc - what the lightbox opens of an original at src (its address on the site) of width × height: an address and that image's size; ok false - the original itself.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL