Пример #1
0
 /**
  *
  * Gallery list
  *
  * @param integer      $post_id
  * @param string       $meta_name Optional. Default: 'gallery'
  * @param string|array $size      thumbnail image size
  *
  * @return array
  */
 public function getGallery($post_id, $meta_name = 'gallery', $size = 'thumbnail')
 {
     $images = array();
     $gallery = $this->get($post_id, $meta_name, false);
     if ($gallery && count($gallery)) {
         foreach ($gallery as $key => $gallery_item) {
             if (!is_null($gallery_item['image']) && '' != $gallery_item['image']) {
                 $attachment_id = Thumbnail::getAttachmentIdFromUrl($gallery_item['image']);
                 $image_html = wp_get_attachment_image($attachment_id, $size);
                 $images[$key] = array('attachment_id' => $attachment_id, 'image_url' => $gallery_item['image'], 'image_html' => $image_html);
             }
         }
     }
     return $images;
 }
Пример #2
0
 /**
  * Returns an HTML image element representing an attachment file.
  *
  * @param string $image_file_url - URL of media
  * @param string $size - size name of image
  *
  * @return string
  * @access public
  * @author Marcin Dobroszek <marcin at silversite.pl>
  */
 function get_attachment_image_from_url($image_file_url, $size = 'thumbnail')
 {
     $attachmentId = Thumbnail::getAttachmentIdFromUrl($image_file_url);
     return wp_get_attachment_image($attachmentId, $size);
 }