Beispiel #1
0
 /**
  * Get media information for the given field
  *
  * @param string $field field name
  * @param string $version version of the media file, as defined in media_processing.conf, can be omitted to retrieve information about all versions
  * @param string $property this is your opportunity to restrict the result to a certain property for the given (field,version) pair.
  * possible values are:
  * -VOLUME
  * -MIMETYPE
  * -WIDTH
  * -HEIGHT
  * -PROPERTIES: returns an array with some media metadata like width, height, mimetype, etc.
  * -FILENAME
  * -HASH
  * -MAGIC
  * -EXTENSION
  * -MD5
  * @return mixed media information
  */
 public function &getMediaInfo($ps_field, $ps_version = null, $ps_property = null)
 {
     $va_media_info = self::get($ps_field, array('returnWithStructure' => true, 'USE_MEDIA_FIELD_VALUES' => true));
     if (!is_array($va_media_info) || !is_array($va_media_info = array_shift($va_media_info))) {
         return null;
     }
     #
     # Use icon
     #
     if ($ps_version && (!$ps_property || in_array($ps_property, array('WIDTH', 'HEIGHT')))) {
         if (isset($va_media_info[$ps_version]['USE_ICON']) && ($vs_icon_code = $va_media_info[$ps_version]['USE_ICON'])) {
             if ($va_icon_size = caGetMediaIconForSize($vs_icon_code, $va_media_info[$ps_version]['WIDTH'], $va_media_info[$ps_version]['HEIGHT'])) {
                 $va_media_info[$ps_version]['WIDTH'] = $va_icon_size['width'];
                 $va_media_info[$ps_version]['HEIGHT'] = $va_icon_size['height'];
             }
         }
     } else {
         if (!$ps_property || in_array($ps_property, array('WIDTH', 'HEIGHT'))) {
             foreach (array_keys($va_media_info) as $vs_version) {
                 if (isset($va_media_info[$vs_version]['USE_ICON']) && ($vs_icon_code = $va_media_info[$vs_version]['USE_ICON'])) {
                     if ($va_icon_size = caGetMediaIconForSize($vs_icon_code, $va_media_info[$vs_version]['WIDTH'], $va_media_info[$vs_version]['HEIGHT'])) {
                         if (!$va_icon_size['size']) {
                             continue;
                         }
                         $va_media_info[$vs_version]['WIDTH'] = $va_icon_size['width'];
                         $va_media_info[$vs_version]['HEIGHT'] = $va_icon_size['height'];
                     }
                 }
             }
         }
     }
     if ($ps_version) {
         if (!$ps_property) {
             return $va_media_info[$ps_version];
         } else {
             // Try key as passed, then all UPPER and all lowercase
             if ($vs_v = $va_media_info[$ps_version][$ps_property]) {
                 return $vs_v;
             }
             if ($vs_v = $va_media_info[$ps_version][strtoupper($ps_property)]) {
                 return $vs_v;
             }
             if ($vs_v = $va_media_info[$ps_version][strtolower($ps_property)]) {
                 return $vs_v;
             }
         }
     } else {
         return $va_media_info;
     }
 }
Beispiel #2
0
 public function getMediaInfo($ps_data, $ps_version = null, $ps_key = null, $pa_options = null)
 {
     if (!($va_media_info = $this->getMediaArray($ps_data))) {
         return false;
     }
     #
     # Use icon
     #
     if ($ps_version && (!$ps_key || in_array($ps_key, array('WIDTH', 'HEIGHT')))) {
         if (isset($va_media_info[$ps_version]['USE_ICON']) && ($vs_icon_code = $va_media_info[$ps_version]['USE_ICON'])) {
             if ($va_icon_size = caGetMediaIconForSize($vs_icon_code, $va_media_info[$ps_version]['WIDTH'], $va_media_info[$ps_version]['HEIGHT'])) {
                 $va_media_info[$ps_version]['WIDTH'] = $va_icon_size['width'];
                 $va_media_info[$ps_version]['HEIGHT'] = $va_icon_size['height'];
             }
         }
     } else {
         if (!$ps_key || in_array($ps_key, array('WIDTH', 'HEIGHT'))) {
             foreach (array_keys($va_media_info) as $vs_version) {
                 if (isset($va_media_info[$vs_version]['USE_ICON']) && ($vs_icon_code = $va_media_info[$vs_version]['USE_ICON'])) {
                     if ($va_icon_size = caGetMediaIconForSize($vs_icon_code, $va_media_info[$vs_version]['WIDTH'], $va_media_info[$vs_version]['HEIGHT'])) {
                         if (!$va_icon_size['size']) {
                             continue;
                         }
                         $va_media_info[$vs_version]['WIDTH'] = $va_icon_size['width'];
                         $va_media_info[$vs_version]['HEIGHT'] = $va_icon_size['height'];
                     }
                 }
             }
         }
     }
     if ($ps_version) {
         if (!$ps_key) {
             return $va_media_info[$ps_version];
         } else {
             return $va_media_info[$ps_version][$ps_key];
         }
     } else {
         return $va_media_info;
     }
 }
/**
 * Attempt to detect faces in image files (TIFF, JPEG, PNG) using OpenCV and the php-facedetect module
 * If php-facedetect and/or OpenCV are not installed then function will return an empty array
 *
 * @param string $ps_type
 * @param int $pn_width  Width of media
 * @param int $pn_height Height of media
 * @param array $pa_options
 *
 * @return string Media ICON <img> tag
 */
function caGetDefaultMediaIconPath($ps_type, $pn_width, $pn_height, $pa_options = null)
{
    if (is_array($va_selected_size = caGetMediaIconForSize($ps_type, $pn_width, $pn_height, $pa_options))) {
        $o_config = Configuration::load();
        $o_icon_config = Configuration::load($o_config->get('default_media_icons'));
        $va_icons = $o_icon_config->getAssoc($ps_type);
        return $o_icon_config->get('icon_folder_path') . '/' . $va_icons[$va_selected_size['size']];
    }
    return null;
}
Beispiel #4
0
 /**
  * Get media information for the given field
  *
  * @param string $field field name
  * @param string $version version of the media file, as defined in media_processing.conf, can be omitted to retrieve information about all versions
  * @param string $property this is your opportunity to restrict the result to a certain property for the given (field,version) pair.
  * possible values are:
  * -VOLUME
  * -MIMETYPE
  * -WIDTH
  * -HEIGHT
  * -PROPERTIES: returns an array with some media metadata like width, height, mimetype, etc.
  * -FILENAME
  * -HASH
  * -MAGIC
  * -EXTENSION
  * -MD5
  * @return mixed media information
  */
 public function &getMediaInfo($ps_field, $ps_version = null, $ps_property = null)
 {
     $va_media_info = self::get($ps_field, array('USE_MEDIA_FIELD_VALUES' => true));
     if (!is_array($va_media_info)) {
         return '';
     }
     #
     # Use icon
     #
     if ($ps_version && (!$ps_property || in_array($ps_property, array('WIDTH', 'HEIGHT')))) {
         if (isset($va_media_info[$ps_version]['USE_ICON']) && ($vs_icon_code = $va_media_info[$ps_version]['USE_ICON'])) {
             if ($va_icon_size = caGetMediaIconForSize($vs_icon_code, $va_media_info[$ps_version]['WIDTH'], $va_media_info[$ps_version]['HEIGHT'])) {
                 $va_media_info[$ps_version]['WIDTH'] = $va_icon_size['width'];
                 $va_media_info[$ps_version]['HEIGHT'] = $va_icon_size['height'];
             }
         }
     } else {
         if (!$ps_property || in_array($ps_property, array('WIDTH', 'HEIGHT'))) {
             foreach (array_keys($va_media_info) as $vs_version) {
                 if (isset($va_media_info[$vs_version]['USE_ICON']) && ($vs_icon_code = $va_media_info[$vs_version]['USE_ICON'])) {
                     if ($va_icon_size = caGetMediaIconForSize($vs_icon_code, $va_media_info[$vs_version]['WIDTH'], $va_media_info[$vs_version]['HEIGHT'])) {
                         if (!$va_icon_size['size']) {
                             continue;
                         }
                         $va_media_info[$vs_version]['WIDTH'] = $va_icon_size['width'];
                         $va_media_info[$vs_version]['HEIGHT'] = $va_icon_size['height'];
                     }
                 }
             }
         }
     }
     if ($ps_version) {
         if (!$ps_property) {
             return $va_media_info[$ps_version];
         } else {
             return $va_media_info[$ps_version][$ps_property];
         }
     } else {
         return $va_media_info;
     }
 }