You are here: start » en » Internal Documentation » DokuWiki extensions (WvdS) » Responsive Image » Quickstart: place an image at the size you want

Quickstart: place an image at the size you want

The shortest way from “the plugin is installed” to “the browser receives a server-side resized image instead of the full file”. Three steps, about five minutes.

Prerequisites

  • wkimage is installed and enabled in the Extension Manager.
  • PHP has an image library for the formats you use (GD or Imagick).
  • An image file in the media store, and permission to edit a page.

Step 1: upload an image

Open the media manager (/doku.php?do=media), pick or create a namespace and upload a file, for example wiki:photo.jpg.

Note the media id — namespace and file name joined by a colon.

Step 2: embed the image

Edit a page and write:

{{wk:image>wiki:photo.jpg?width=800}}

Options after the ? follow query-string form; several are joined with &.

Step 3: add the accessible text

{{wk:image>wiki:photo.jpg?width=800&alt=View of the assembly hall}}

alt is what a screen reader announces and what the browser shows when the image fails. An image that carries meaning needs it.

Check the result

  • The image is on the page. The decisive difference is visible in the HTML source: what is delivered is an 800-pixel version, not the original scaled down by CSS.
  • The attribute loading=“lazy” sits on the element — lazy loading is the default. For an image visible without scrolling switch it off with &lazy=0; otherwise the reader waits for something already on screen.
  • Reload the page. The image comes from the cache, it is not resized again. Ask for a different width and a second cached result appears; the first stays.
On this installation defaultMaxWidth is 800. Without an explicit width the image is therefore capped at 800 pixels.

Next step

  • wkopengraph — if the same image should serve as the preview card when the page is shared.
  • wkimage (German) — the package page: every option (maxwidth, quality, format, inline), the settings and the PHP helper.
en/wiki/dwe/wkimage/quickstart.txt · Last modified: by 0.0.0.0