public function actionPhoto($albumid) { $pic = new Picasa(); $album = $pic->getAlbumById($this->username, $albumid, null, null, null, null, null, 1000); $images = $album->getImages(); $albumTitle = $album->getTitle(); //add meta tag fb Yii::app()->clientScript->registerMetaTag('1551369015136719', NULL, NULL, array('property' => 'fb:app_id')); Yii::app()->clientScript->registerMetaTag($albumTitle, NULL, NULL, array('property' => 'og:title')); Yii::app()->clientScript->registerMetaTag('article', NULL, NULL, array('property' => 'og:type')); foreach ($images as $image) { Yii::app()->clientScript->registerMetaTag($image->getContent(), NULL, NULL, array('property' => 'og:image')); } Yii::app()->clientScript->registerMetaTag(Yii::app()->getRequest()->getHostInfo() . Yii::app()->request->requestUri, NULL, NULL, array('property' => 'og:url')); Yii::app()->clientScript->registerMetaTag('Trang web chia sẻ ảnh và video của An An Cute', NULL, NULL, array('property' => 'og:description')); $this->pageTitle = 'An An Cute - ' . $albumTitle; $this->render('photo', array('images' => $images, 'albumid' => $albumid, 'albumTitle' => $albumTitle)); }
function get_album($user, $album_id, $images_width = NULL) { if ($images_width == NULL) { $images_width = '200,800'; } // $images_width - размер возвращаемых изображений // для любителей кэша тут код а-ля, если есть кеш, берем данные из кеша: /* if (file_exists($_SERVER['DOCUMENT_ROOT'].'/cache/picasa_api_cache/'.$user.'/'.$album_name) ) { $album_data = unserialize(file_get_contents($_SERVER['DOCUMENT_ROOT'].'/cache/picasa_api_cache/'.$user.'/'.$album_name)); } else { // и нужно закрыть ручками это условие в конце функции */ $pic = new Picasa(); // Получаем данные для альбома, в последнем параметре указываем размеры необходимых изображений. // Можно также указать размеры: 72, 144, 200, 320, 400, 512, 576, 640, 720, 800, 912, 1024, 1152, 1280, 1440, 1600 // googlesystem.blogspot.com/2006/12/embed-photos-from-picasa-web-albums.html $album = $pic->getAlbumById($user, $album_id, null, null, null, null, $images_width); // Получаем данные о изображениях в альбоме $images = $album->getImages(); foreach ($images as $image) { $thumbnails = $image->getThumbnails(); $album_data['images'][] = array('url' => (string) $thumbnails[1]->getUrl(), 'width' => (string) $thumbnails[1]->getWidth(), 'height' => (string) $thumbnails[1]->getHeight(), 'title' => (string) $image->getDescription(), 'tn_url' => (string) $thumbnails[0]->getUrl(), 'tn_width' => (string) $thumbnails[0]->getWidth(), 'tn_height' => (string) $thumbnails[0]->getHeight()); } // иконка альбома $album_data['url'] = (string) $album->getIcon(); $album_data['width'] = '160'; $album_data['height'] = '160'; $album_data['title'] = (string) $album->getTitle(); // сохраняем данные в кеш (оставил это для тех кому нужно) //if(!is_dir($_SERVER['DOCUMENT_ROOT'].$cache_path.$user)) //mkdir($_SERVER['DOCUMENT_ROOT'].$cache_path.$user,0777); //file_put_contents($_SERVER['DOCUMENT_ROOT'].$cache_path.$user.'/'.$album_name,serialize($album_data)); return $album_data; }
/** * The $images feild can somtimes be null because it's not always included in the XML used to create some objects. If * that is the case, query the album feed using {@link Picasa::getAlbumById()} to get the images in the album. This * is done when the client tries to access the images array so that it's not done if it's not requested. * * @return array * @access public */ public function getImages() { /* If $this originally came from xml in an Account object, $this->images will be null. In that case, get the album directly from a url, which will include all the images, and then just take the images field from that album. A tad inneficient, but only marginally so. And it's better than just not having access to the images. */ if ($this->images === null && $this->numphotos > 0) { Picasa_Logger::getLogger()->logIfEnabled("Images was null, requesting from Picasa..."); if ($this->picasaAuthor !== null) { $picasa = new Picasa(null, null, null, $this->contextArray); $album = $picasa->getAlbumById($this->picasaAuthor->getUser(), $this->idnum); $this->images = $album->getImages(); } } return $this->images; }
/** * Loads the private members $previous and $next with the previous and next * images in their album. * * @return void * @access private */ private function loadPreviousAndNext() { $albumid = $this->getAlbumid(); $pic = new Picasa(null, null, null, $this->contextArray); $user = $this->author->getUser(); $album = $pic->getAlbumById($user, $albumid); $images = $album->getImages(); $count = count($images); $selectedId = $this->idnum; // Find the current image in its album for ($i = 0; $i < $count && strcmp($images[$i]->getIdnum(), $selectedId) != 0; $i++) { } if ($i === 0) { $this->previous = null; } else { $this->previous = $images[$i - 1]; } if ($i === $count) { $this->next = null; } else { $this->next = $images[$i + 1]; } }
$html .= " <h5>" . $album->getTitle() . "</h5>\n"; $html .= " <p>" . WpEspritPicasa::gDate('D jS F Y', $album->getTimestamp()) . " (photos: " . $album->getNumphotos() . ")</p>\n"; $html .= " </div>\n"; if (($i + 1) % $albumsPerRow == 0) { $html .= "</div>\n"; $html .= "<div class='clear'><br></div>"; } $i++; } } else { $javascript = "<script type='text/javascript'>\n"; $html .= "<div id=\"PicasaNavigation\">\n"; $html .= " <a href=\"" . $_SERVER["PHP_SELF"] . "?" . $uriParams . "\">Back to Albums</a>\n"; $html .= " <div class='clear'><br></div>\n"; $html .= "</div>"; $images = $picasa->getAlbumById(get_option(WpEspritPicasa::$WP_OPTION_USERNAME), $albumId, null, null, null, null, $albumThumbnailSize . "c," . get_option(WpEspritPicasa::$WP_OPTION_THUMBNAIL_SIZE) . "," . get_option(WpEspritPicasa::$WP_OPTION_FULL_SIZE) . "," . get_option(WpEspritPicasa::$WP_OPTION_PEREX_SIZE))->getImages(); $javascript .= "var picasaImagesArray = new Array();\n"; foreach ($images as $image) { $thumbnails = $image->getThumbnails(); $javascript .= "picasaImageObject = new Object();\n"; $javascript .= "picasaImageObject.linkPerex = '" . $thumbnails[3]->getUrl() . "';\n"; $javascript .= "picasaImageObject.description = '" . $image->getDescription() . "';\n"; $javascript .= "picasaImagesArray['" . $image->getTitle() . "'] = picasaImageObject;\n"; $html .= $i % $albumsPerRow == 0 ? "<div class=\"row\">\n" : ""; $html .= " <div class=\"PicasaPhotos\">\n"; if ($tab && $tab == "thumbnail") { $html .= " <a href=\"#\" onclick=\"return false\">\n"; $html .= " <img class=\"Thumbnail\" name=\"" . $image->getTitle() . "\" src=\"" . $thumbnails[0]->getUrl() . "\" width=\"" . $albumThumbnailSize . "px\" height=\"" . $albumThumbnailSize . "px\">\n"; $html .= " </a>\n"; } else { $html .= " <a href=\"#\" onclick=\"return picasaAddPhoto('" . $thumbnails[2]->getUrl() . "','" . $thumbnails[1]->getUrl() . "','" . $image->getTitle() . "','" . $image->getDescription() . "','" . $_REQUEST[WpEspritPicasa::$REQUEST_PARAMETER_POST_ID] . "')\">\n";