Dokuwiki - Media

Card Puncher Data Processing

About

This page is showing snippet on how to manage media

Snippets

Image in page via Renderer

Via the renderer, you have the internalmedia and externalmedia method.

Image in a page via instructions

From plugin-medialist

protected function _lookup_linked_media($id) {
	$linked_media = array();

	if (!page_exists($id)) {
		//msg('MediaList: page "'. hsc($id) . '" not exists!', -1); 
	}

	if (auth_quickaclcheck($id) >= AUTH_READ) {
		// get the instructions
		$ins = p_cached_instructions(wikiFN($id), true, $id);

		// get linked media files
		foreach ($ins as $node) {
			if ($node[0] == 'internalmedia') {
				$id = cleanID($node[1][0]);
				$fn = mediaFN($id);
				if (!file_exists($fn)) continue;
				$linked_media[] = array(
					'id'    => $id,
					'size'  => filesize($fn),
					'mtime' => filemtime($fn),
					'type'  => $node[0],
				);
			} elseif ($node[0] == 'externalmedia') {
				$linked_media[] = array(
					'id'    => $node[1][0],
					'size'  => null,
					'mtime' => null,
					'type'  => $node[0],
				);
			}
		}

	}
	return array_unique($linked_media, SORT_REGULAR);
}

Pages using an image

On the Dokuwiki - Index, you can get the page using a image with:

$result = idx_get_indexer()->lookupKey('relation_media', $id);

Metadata gives the first image

The metadata firstimage gives the first image

$src = p_get_metadata($id,'relation firstimage');
     if(!$flags['firstimage'] || !@file_exists(mediaFN($src))) {
     return $this->getConf('default_image');
}







Share this page:
Follow us:
Task Runner