/**
 * 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;
}
 function WiziappMediaExtractor($html)
 {
     //        $GLOBALS['WiziappLog']->write('info', ">>>The html for the post is {$html}", 'WiziappMediaExtractor');
     $encoding = get_bloginfo('charset');
     if (!empty($html)) {
         $dom = new WiziappDOMLoader($html, $encoding);
         $this->_process($dom->getBody());
     }
 }
Exemplo 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;
}