|
Cookbook /
BackgroundImagesSummary: How to add background images to divisions, tables & cells
Status: Stable
Version: 1
Prerequisites: pmwiki-2.0
Maintainer:
Discussion: BackgroundImages-Talk
Categories: Images
Votes:
QuestionHow can I use background images for divisions, tables and table cells? Answerstyle='background-image...'The url location for use as a background image can be included in a style declaration as This can be done in markup for $FmtPV['$PubDirUrl'] = '$GLOBALS["PubDirUrl"]';
Then use it in the url for the background image for instance like url({$PubDirUrl}/images/image.file)
Wrong: if you use a url variable, the full path will be rendered as a link, as stated above, making the style attribute invalid. Actually there is no way to specify domain-independent full paths for style attributes in Pmwiki Note also that you cannot use Attach:image.ext Δ syntax inside the url. Examples:A division with a background image. A relative path is used.
Markup (:background:)To apply background-image styling to divisions not defined on the wiki page, like the whole wikitext division, you can use a custom markup: Set in config.php:
Markup('background', 'directives',
'/\\(:background(\\s.*?)?:\\)/e',
"Background(\$pagename, ParseArgs(PSS('$1')))");
function Background ($pagename, $opt) {
global $HTMLStylesFmt;
foreach($opt as $divname => $value) {
$HTMLStylesFmt[] = " #$divname { background:$value } \n ";
}
};
Usage:
divname is any division name, like wikitext, or as used in Gemini and Fixflow skins: content, sidebar etc (check your skin tmpl for divs, there are big variations in naming divs) without the leading # sign. Background attributes are any css attr. for background (including background image url), like color-names, color-codes,
url(http://site/path/bgimage),
no-repeat, repeat-x, repeat-y, center etc.
Use attributes as words without commas. Example:
You can have several divnames in the markup, like content=#fed sidebar=#def etc. See Also
ContributorsCategory: Images
SandboxBackground image opacity is also applied to the text, making it less usefull: It's a BACKGROUND image... at the back of the page content. Why would you apply opacity to it? Just prepare the base image with the require amount of fading. A division with a background image. CommentsSee discussion at BackgroundImages-Talk User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |