Пример #1
0
/**
 * @package     jelix
 * @subpackage  jtpl_plugin
 * @author      Lepeltier kévin
 * @contributor Dominique Papin, Rob2
 * @copyright   2007-2008 Lepeltier kévin, 2008 Dominique Papin, 2010 Rob2
 * @link        http://www.jelix.org
 * @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
 */
function jtpl_function_html_image($tpl, $src, $params = array())
{
    $att = jImageModifier::get($src, $params, false);
    if (!array_key_exists('alt', $att)) {
        $att['alt'] = '';
    }
    echo '<img';
    foreach ($att as $key => $val) {
        if (!empty($val) || $key == 'alt') {
            echo ' ' . $key . '="' . htmlspecialchars($val) . '"';
        }
    }
    echo '/>';
}
Пример #2
0
/**
 * image plugin :  write the url corresponding to the image
 *
 * Add a link to the image,
 * The image is resized, and cached
 *
 * class :string
 * id :string
 * alt :string
 * width :uint
 * height :uint
 * maxwidth :uint only with maxheight
 * maxheight :uint only with maxwidth
 * zoom 1-100
 * omo :boolean
 * alignh [left|center|right|:int]
 * alignv [top|center|bottom|:int]
 * ext [png|jpg|gif]
 * quality 0-100 if ext = jpg
 * shadow :boolean
 * soffset :uint
 * sangle :uint
 * sblur :uint
 * sopacity :uint
 * scolor #000000 :string
 * background #000000 :string
 *
 * gif   -> image/gif
 * jpeg  -> image/jpeg
 * jpg   -> image/jpeg
 * jpe   -> image/jpeg
 * xpm   -> image/x-xpixmap
 * xbm   -> image/x-xbitmap
 * wbmp  -> image/vnd.wap.wbmp
 * png   -> image/png
 * other -> image/png
 *
 * @param jTpl $tpl template engine
 * @param string $src the url of image relative to the www path
 * @param array $params parameters for the transformation and img element
 */
function jtpl_function_html_image($tpl, $src, $params = array())
{
    $att = jImageModifier::get($src, $params, false);
    // alt attribute is required (xhtml/html4 spec)
    if (!array_key_exists('alt', $att)) {
        $att['alt'] = '';
    }
    // generating hmtl tag img
    echo '<img';
    foreach ($att as $key => $val) {
        if (!empty($val)) {
            echo ' ' . $key . '="' . htmlspecialchars($val) . '"';
        }
    }
    echo '/>';
}
 function testGetOmo2()
 {
     $cacheName = 'cache/images/' . md5('imagemodifier/logo_test.pngwidth50height30omo1') . '.png';
     $cacheFile = jApp::wwwPath($cacheName);
     if (file_exists($cacheFile)) {
         unlink($cacheFile);
     }
     $attributes = jImageModifier::get('imagemodifier/logo_test.png', array('width' => 50, 'height' => 30, 'omo' => true));
     $this->assertEqual($GLOBALS['gJCoord']->request->getServerURI() . $GLOBALS['gJConfig']->urlengine['basePath'] . $cacheName, $attributes['src']);
     $this->assertEqual('50', $attributes['width']);
     $this->assertEqual('30', $attributes['height']);
     $this->assertTrue(file_exists($cacheFile));
     $image = imagecreatefrompng($cacheFile);
     $this->assertEqual(50, imagesx($image));
     $this->assertEqual(30, imagesy($image));
     @imagedestroy($image);
     if (file_exists($cacheFile)) {
         unlink($cacheFile);
     }
 }
/**
 * function that builds the image of the social network
 * @param string $src url to link to
 * @param array  $params parms to build the image
 */
function make_image($src, $params)
{
    $att = jImageModifier::get($src, $params, false);
    // alt attribute is required (xhtml/html4 spec)
    if (!array_key_exists('alt', $att)) {
        $att['alt'] = '';
    }
    // generating hmtl tag img
    $img = '<img';
    foreach ($att as $key => $val) {
        if (!empty($val)) {
            $img .= ' ' . $key . '="' . htmlspecialchars($val) . '"';
        }
    }
    $img .= ' />';
    return $img;
}