img

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TagOpen = []byte("<img")

	AttrSrc            = []byte(" src=\"")
	AttrAlt            = []byte(" alt=\"")
	AttrWidth          = []byte(" width=\"")
	AttrHeight         = []byte(" height=\"")
	AttrLoading        = []byte(" loading=\"")
	AttrSizes          = []byte(" sizes=\"")
	AttrSrcset         = []byte(" srcset=\"")
	AttrCrossOrigin    = []byte(" crossorigin=\"")
	AttrDecoding       = []byte(" decoding=\"")
	AttrFetchPriority  = []byte(" fetchpriority=\"")
	AttrReferrerPolicy = []byte(" referrerpolicy=\"")
	AttrIsMap          = []byte(" ismap")
	AttrUseMap         = []byte(" usemap=\"")
	AttrAttributionSrc = []byte(" attributionsrc=\"")
	AttrElementTiming  = []byte(" elementtiming=\"")
)

Byte constants for HTML rendering.

Functions

func Eager

func Eager(src string, alt string) *element

Eager Creates an img element with eager loading for immediate display. Example: img.Eager("logo.png", "Company Logo") Renders: <img src="logo.png" alt="Company Logo" loading="eager" /> Note: Image loads immediately, regardless of viewport position

func Image

func Image(src string, alt string) *element

Image Creates an img element with source and alt text for accessibility. Example: img.Image("photo.jpg", "A beautiful sunset") Renders: <img src="photo.jpg" alt="A beautiful sunset" />

func Lazy

func Lazy(src string, alt string) *element

Lazy Creates an img element with lazy loading enabled for improved performance. Example: img.Lazy("photo.jpg", "A sunset") Renders: <img src="photo.jpg" alt="A sunset" loading="lazy" /> Note: Image will only load when it enters or is near the viewport

func New

func New() *element

New Creates a new img element without any initial attributes. Example: img.New().Src("photo.jpg").Alt("A beautiful sunset") Renders: <img src="photo.jpg" alt="A beautiful sunset" />

func Src

func Src(src string) *element

Src Creates an img element with the specified source. Example: img.Src("photo.jpg") Renders: <img src="photo.jpg" /> Note: Consider using Image() for accessibility

Types

type Element

type Element = element

Element is an exported alias for the private element type

Jump to

Keyboard shortcuts

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