'img', 'auto_activate' => true, 'requires_pair' => false, 'load_function' => '\data_img', 'title' => 'Image', 'help_page' => 'DataPluginImg', 'description' => KernelTools::tra( "Allows you to insert an image into your page with little effort and a multitude of styling options." ), 'help_function' => '\data_img_help', 'syntax' => "{img src=http://www.google.at/logos/olympics06_ski_jump.gif}", 'plugin_type' => DATA_PLUGIN, 'booticon' => '{biticon ipackage="icons" iname="image-x-generic" iexplain="Web Image"}', 'taginsert' => '{img src= width= height= align= description= link=}', ]; $gLibertySystem->registerPlugin( PLUGIN_GUID_DATAIMG, $pluginParams ); $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAIMG ); function data_img_help() { return '' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'
'.KernelTools::tra( "Key" ).''.KernelTools::tra( "Type" ).''.KernelTools::tra( "Comments" ).'
src'.KernelTools::tra( "string").'
'.KernelTools::tra("(required)").'
'.KernelTools::tra( "Specify where the path to the image.").'
link'.KernelTools::tra( "string").'
'.KernelTools::tra("(optional)").'
'.KernelTools::tra( "If you want your image to link to a web address, use link='link/to/page'." ).'
'.KernelTools::tra( "styling" ).''.KernelTools::tra( "string").'
'.KernelTools::tra("(optional)").'
'.KernelTools::tra( "Multiple styling options available: padding, margin, background, border, text-align, color, font, font-size, font-weight, font-family, align. Please view CSS guidelines on what values these settings take.").'
' . KernelTools::tra( "Example: ")."{img src=http://www.google.at/logos/olympics06_ski_jump.gif float=right border=\"3px solid blue\"}"; } function data_img( $pData, $pParams ) { $cssStyle = ''; $cssClass = ''; foreach( $pParams as $key => $value ) { if( !empty( $value ) ) { switch( $key ) { // rename a couple of parameters case 'width': case 'height': if( preg_match( "/^\d+(em|px|%|pt)$/", trim( $value ) ) ) { $cssStyle .= $key.':'.$value.';'; } elseif( preg_match( "/^\d+$/", $value ) ) { $cssStyle .= $key.':'.$value.'px;'; } // remove values from the hash that they don't get used in the div as well $pParams[$key] = null; break; case 'class': $cssClass .= $value.' '; break; case 'style': $cssStyle .= ';'.$value; break; } } } $wrapper = \Bitweaver\Liberty\liberty_plugins_wrapper_style( $pParams ); // check if we have a source to load an image from if( !empty( $pParams['src'] ) ) { // set up image first $alt = !empty( $wrapper['description'] ) ? $wrapper['description'] : KernelTools::tra( 'Image' ); $ret = ''.$alt.''; // if this image is linking to something, wrap the image with the if( !empty( $wrapper['link'] ) ) { $ret = ''.$ret.''; } // finally, wrap the image if( !empty( $wrapper['style'] ) || !empty( $class ) || !empty( $wrapper['description'] ) ) { $ret = '<'.$wrapper['wrapper'].' class="img-plugin" style="'.$wrapper['style'].'">'.$ret.( !empty( $wrapper['description'] ) ? '
'.$wrapper['description'] : '' ).''; } } else { $ret = ''.KernelTools::tra( 'When using {img} the src parameter is required.' ).''; } return $ret; }