Documentation
¶
Overview ¶
Package img provides constructors and methods for the HTML <img> element.
The <img> HTML element embeds an image into the document, displaying graphics, photographs, illustrations, or visualizations. Supports responsive images via srcset and sizes, lazy loading for performance, and various decoding strategies. The alt attribute is essential for accessibility. Used for content images, logos, icons, diagrams, and any visual content integral to page meaning.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
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