/**
 * get all images in album from wordpress
 * @param array $images - images
 * @param string $albumId - album id
 * @param int $postId - post id
 * @return array
 */
function wiziapp_get_wordpress_album($images = array(), $postId = 0, $albumId = 0)
{
    $images = array();
    if (empty($postId)) {
        return $images;
    }
    $data = $GLOBALS['WiziappDB']->get_media_data('image', 'wordpress-gallery-id', $postId);
    if ($data !== FALSE) {
        $GLOBALS['WiziappLog']->write('info', "The Wordpress album is " . print_r($data[$postId], TRUE), 'wordpress_plugin.wiziapp_get_wordpress_album');
        foreach ($data as $image) {
            $encoding = get_bloginfo('charset');
            $dom = new WiziappDOMLoader($image['original_code'], $encoding);
            $tmp = $dom->getBody();
            $attributes = (object) $tmp[0]['img']['attributes'];
            $info = json_decode($image['attachment_info']);
            $image_info = $info->attributes;
            $title = '';
            if (isset($image_info->title)) {
                $title = "{$image_info->title}";
            }
            $image_out = array('pid' => (int) $image['id'], 'thumbURL' => (string) $image_info->src, 'imageURL' => (string) $attributes->src, 'description' => $title, 'relatedPost' => (int) $postId, 'alttext' => $title);
            $images[] = $image_out;
        }
    }
    return $images;
}
 /**
  * _appendToArray
  * 
  * Add the processed object to the right array according to its type
  * there it will wait till we save it
  * 
  * @param array $obj the processed object
  * @param array $element the original element
  * @param string $type the type of the element: videos, images, audios
  */
 function _appendToArray($obj, $element, $type)
 {
     $added = FALSE;
     if (!empty($obj)) {
         // We might need to override the type
         if (!empty($obj['type']) && $obj['type'] != $type) {
             if (isset($this->{$type}) && is_array($this->{$type})) {
                 $type = $obj['type'];
             }
         }
         $dom = new WiziappDOMLoader();
         $html = $dom->getNodeAsHTML(array($element));
         $this->{$type}[] = array('obj' => $obj, 'html' => $html);
         $added = TRUE;
     }
     return $added;
 }
Ejemplo n.º 3
0
function wiziapp_tryGalleryThumbnail($post, $size, $limitSize, &$singles)
{
    $post_media = $GLOBALS['WiziappDB']->find_post_media($post, 'image');
    $showedImage = FALSE;
    if (!empty($post_media)) {
        $singlesCount = count($singles);
        $galleryCount = 0;
        foreach ($post_media as $media) {
            $encoding = get_bloginfo('charset');
            $dom = new WiziappDOMLoader($media['original_code'], $encoding);
            $tmp = $dom->getBody();
            $attributes = (object) $tmp[0]['img']['attributes'];
            $info = json_decode($media['attachment_info']);
            if (!isset($info->metadata)) {
                // Single image
                if ($singlesCount < WiziappConfig::getInstance()->max_thumb_check) {
                    $singles[] = $attributes->src;
                    ++$singlesCount;
                }
            } else {
                if ($galleryCount < WiziappConfig::getInstance()->max_thumb_check) {
                    if ($showedImage = wiziapp_processImageForThumb($attributes->src, $size, $limitSize)) {
                        return $showedImage;
                    }
                    ++$galleryCount;
                }
            }
        }
    }
    return $showedImage;
}