示例#1
0
<?php

// module: magnific_popup_image_out
$imageType = 'magnific_popup_image_thumb';
$imageFile = 'REX_MEDIA[1]';
if ($imageFile != '') {
    $media = OOMedia::getMediaByFilename($imageFile);
    // get title and description
    if (OOMedia::isValid($media)) {
        $title = $media->getValue('title');
        $description = $media->getValue('med_description');
    } else {
        $title = '';
        $description = '';
    }
    // get media dir
    if (isset($REX['MEDIA_DIR'])) {
        $mediaDir = $REX['MEDIA_DIR'];
    } else {
        $mediaDir = 'files';
    }
    // generate image manager url
    if (method_exists('seo42', 'getImageManagerFile')) {
        $imageManagerUrl = seo42::getImageManagerFile($imageFile, $imageType);
        $imageUrl = seo42::getMediaDir() . $imageFile;
    } elseif (method_exists('seo42', 'getImageManagerUrl')) {
        // compat
        $imageManagerUrl = seo42::getImageManagerUrl($imageFile, $imageType);
        $imageUrl = seo42::getMediaDir() . $imageFile;
    } else {
        $imageUrl = $REX['HTDOCS_PATH'] . $mediaDir . '/' . $imageFile;
示例#2
0
 public static function getImageTag($imageFile, $imageType = '', $width = 0, $height = 0)
 {
     $media = OOMedia::getMediaByFileName($imageFile);
     // make sure media object is valid
     if (OOMedia::isValid($media)) {
         $mediaWidth = $media->getWidth();
         $mediaHeight = $media->getHeight();
         $altAttribute = $media->getTitle();
     } else {
         $mediaWidth = '';
         $mediaHeight = '';
         $altAttribute = '';
     }
     // image width
     if ($width == 0) {
         $imgWidth = $mediaWidth;
     } else {
         $imgWidth = $width;
     }
     // image height
     if ($height == 0) {
         $imgHeight = $mediaHeight;
     } else {
         $imgHeight = $height;
     }
     // get url
     if ($imageType == '') {
         $url = self::getMediaFile($imageFile);
     } else {
         $url = self::getImageManagerFile($imageFile, $imageType);
     }
     return '<img src="' . $url . '" width="' . $imgWidth . '" height="' . $imgHeight . '" alt="' . $altAttribute . '" />';
 }