Esempio n. 1
0
 /**
  * Format the value of the property before it's returned
  * to WordPress admin or the site.
  *
  * @param  mixed  $value
  * @param  string $slug
  * @param  int    $post_id
  *
  * @return mixed
  */
 public function format_value($value, $slug, $post_id)
 {
     if (is_numeric($value)) {
         $meta = wp_get_attachment_metadata($value);
         if (isset($meta) && !empty($meta)) {
             $att = get_post($value);
             $mine = ['alt' => trim(strip_tags(get_post_meta($value, '_wp_attachment_image_alt', true))), 'caption' => trim(strip_tags($att->post_excerpt)), 'description' => trim(strip_tags($att->post_content)), 'id' => intval($value), 'is_image' => (bool) wp_attachment_is_image($value), 'title' => esc_html($att->post_title), 'url' => wp_get_attachment_url($value)];
             $meta = is_array($meta) ? $meta : ['file' => $meta];
             if (isset($meta['sizes'])) {
                 foreach (array_keys($meta['sizes']) as $size) {
                     if ($src = wp_get_attachment_image_src($mine['id'], $size)) {
                         $meta['sizes'][$size]['url'] = $src[0];
                     }
                 }
             }
             return (object) array_merge($meta, $mine);
         }
         return (int) $value;
     }
     if (is_array($value)) {
         foreach ($value as $k => $v) {
             $value[$k] = $this->format_value($v, $slug, $post_id);
         }
         return $value;
     }
     if (is_object($value) && !isset($value->url)) {
         return;
     }
     return $value;
 }
 /**
  * Migrate a single attachment's files to S3
  *
  * @subcommand migrate-attachment
  * @synopsis <attachment-id> [--delete-local]
  */
 public function migrate_attachment_to_s3($args, $args_assoc)
 {
     // Ensure things are active
     $instance = S3_Uploads::get_instance();
     if (!s3_uploads_enabled()) {
         $instance->setup();
     }
     $old_upload_dir = $instance->get_original_upload_dir();
     $upload_dir = wp_upload_dir();
     $files = array(get_post_meta($args[0], '_wp_attached_file', true));
     $meta_data = wp_get_attachment_metadata($args[0]);
     if (!empty($meta_data['sizes'])) {
         foreach ($meta_data['sizes'] as $file) {
             $files[] = path_join(dirname($meta_data['file']), $file['file']);
         }
     }
     foreach ($files as $file) {
         if (file_exists($path = $old_upload_dir['basedir'] . '/' . $file)) {
             if (!copy($path, $upload_dir['basedir'] . '/' . $file)) {
                 WP_CLI::line(sprintf('Failed to moved %s to S3', $file));
             } else {
                 if (!empty($args_assoc['delete-local'])) {
                     unlink($path);
                 }
                 WP_CLI::success(sprintf('Moved file %s to S3', $file));
             }
         } else {
             WP_CLI::line(sprintf('Already moved to %s S3', $file));
         }
     }
 }
/**
 * Builds the Smart Image shortcode output.
 *
 * Allows a plugin to replace the content that would otherwise be returned. The
 * filter is 'img_smart_image_shortcode' and passes an empty string, the attr
 * parameter and the content parameter values.
 *
 * The supported attributes for the shortcode are 'id', 'align', 'width', and
 * 'caption'.
 *
 * @since 2.6.0
 *
 * @param array  $attr {
 *     Attributes of the caption shortcode.
 *
 *     @type string $id      ID of the div element for the caption.
 *     @type string $align   Class name that aligns the caption. Default 'alignnone'. Accepts 'alignleft',
 *                           'aligncenter', alignright', 'alignnone'.
 *     @type int    $width   The width of the caption, in pixels.
 *     @type string $caption The caption text.
 *     @type string $class   Additional class name(s) added to the caption container.
 * }
 * @param string $content Shortcode content.
 * @return string HTML content to display the caption.
 */
function img_smart_image_shortcode($attr, $content = null)
{
    // New-style shortcode with the caption inside the shortcode with the link and image tags.
    $image_meta = wp_get_attachment_metadata($attr['image_id']);
    // gets the images
    $image_large = wp_get_attachment_image_src($attr['image_id'], 'full');
    $image_md = wp_get_attachment_image_src($attr['image_id'], 'medium-hero-png');
    $image_sm = wp_get_attachment_image_src($attr['image_id'], 'small-hero-png');
    $placeholder = wp_get_attachment_image_src($attr['image_id'], 'apple-square-76');
    // update to
    // Sets up the images array
    $images = array('(max-width:640px)' => $image_sm[0], '(min-width:640px)' => $image_md[0], '(min-width:1000px)' => $image_large[0]);
    // encodes the images array for future use in Javascript
    $images = base64_encode(json_encode($images));
    // If this image has zoom enabled, we turn it on here.
    $has_zoom = isset($attr['zoom']) && $attr['zoom'] === 'true' ? true : false;
    $has_zoom = $has_zoom ? ' has_zoom' : '';
    $has_bleed = false;
    // if the image hasn't been uploaded through the dashboard, we make it so that a string is echo'd to find those bugs.
    echo $image_meta === false ? 'Looks like image ' . $attr['image_id'] . ' hasn\'t been uploaded through the dashboard.' : '';
    // Sets the maximum width of the current image.
    $css_max_width = ' style="max-width:100%"';
    // If this image has bleed, but it's turned off
    if (!isset($attr['bleed']) || isset($attr['bleed']) && $attr['bleed'] === "false") {
        // set the image width if it's a retina image
        $css_max_width = isset($attr['retina']) && $attr['retina'] === true ? ' style="max-width:' . $image_large[1] / 2 . 'px;"' : ' style="max-width:' . $image_large[1] . 'px;"';
        // set the image width if it's a standard image
        if (isset($attr['retina']) && $attr['retina'] !== true) {
            $css_max_width = isset($attr['width']) && $attr['width'] !== true ? ' style="max-width:' . $attr['width'] . 'px;"' : $css_max_width;
        }
    } else {
        // otherwise, set bleed on.
        $has_bleed = ' has_bleed';
        $css_max_width = ' style="max-width:100%"';
    }
    // Sets the aspect ratio
    $css_padding_bottom = $image_large[1] !== null && $image_large[2] !== null ? $image_large[2] / $image_large[1] * 100 . '%' : 0;
    // begin creating the $final_image video with for the javascript to parse.
    $final_image = '<figure id="' . $attr['image_id'] . '" class="progressive_image js-not_loaded' . $has_zoom . $has_bleed . '" width="' . $attr['width'] . '" height="' . $attr['height'] . '" style="max-width:' . $attr['width'] . 'px;" itemscope="" itemtype="http://schema.org/ImageObject">';
    $final_image .= '<div class="aspect_ratio_placeholder"' . $css_max_width . '  style="background-image:url(\'' . $image_sm->url . '\');">';
    $final_image .= '<div class="aspect_ratio_fill" style="padding-bottom:' . $css_padding_bottom . ';"></div>';
    // this div keeps the aspect ratio so the placeholder doesn't collapse
    $final_image .= '<div class="progressiveMedia is-imageLoaded"' . $css_max_width . '>';
    $final_image .= '<img src="' . $placeholder[0] . '" class="low-quality-image"' . $css_max_width . ' itemscope="contentUrl" content="' . $image_lg->url . '"/>';
    // this is a tiny image with a resolution of e.g. ~27x17 and low quality
    // 		<canvas/> <!-- takes the above image and applies a blur filter -->
    $final_image .= '<div class="js-swap-for-picture" data-image_info="' . $images . '"></div>';
    // <!-- the large image to be displayed -->
    $no_script_image = '<img class="progressiveMedia-noscript js-progressiveMedia-inner" src="' . $image_large[0] . '" data-action="zoom" />';
    $final_image .= '<noscript>' . $no_script_image . '</noscript>';
    // fallback for no JS
    $final_image .= '</div>';
    $final_image .= '</div>';
    // If this image has a caption, echo it here.
    if ($content) {
        $final_image .= '<figcaption class="wp-caption-text">' . $content . '</figcaption>';
    }
    $final_image .= '</figure>';
    return $final_image;
}
Esempio n. 4
0
 /**
  * Resize images dynamically using wp built in functions
  *
  * @param string $img_url
  * @param int $width
  * @param int $height
  * @param bool $crop
  * @return array
  */
 function themify_do_img($img_url = null, $width, $height, $crop = false)
 {
     $src = esc_url($img_url);
     $upload_dir = wp_upload_dir();
     $base_url = $upload_dir['baseurl'];
     // Check if the image is an attachment. If it's external return url, width and height.
     if (substr($src, -strlen($base_url)) === $base_url) {
         return array('url' => $src, 'width' => $width, 'height' => $height);
     }
     // Get post's attachment meta data to look for references to the requested image size
     $attachment_id = themify_get_attachment_id_from_url($src, $base_url);
     // If no relationship between a post and a image size was found, return url, width and height.
     if (!$attachment_id) {
         return array('url' => $src, 'width' => $width, 'height' => $height);
     }
     // Go through the attachment meta data sizes looking for an image size match.
     $meta = wp_get_attachment_metadata($attachment_id);
     if (is_array($meta) && isset($meta['sizes']) && is_array($meta['sizes'])) {
         foreach ($meta['sizes'] as $key => $size) {
             if ($size['width'] == $width && $size['height'] == $height) {
                 setlocale(LC_CTYPE, get_locale() . '.UTF-8');
                 return array('url' => str_replace(basename($src), $size['file'], $src), 'width' => $width, 'height' => $height);
             }
         }
     }
     // Requested image size doesn't exists, so let's create one
     if (true == $crop) {
         add_filter('image_resize_dimensions', 'themify_img_resize_dimensions', 10, 5);
     }
     $image = themify_make_image_size($attachment_id, $width, $height, $meta, $src);
     if (true == $crop) {
         remove_filter('image_resize_dimensions', 'themify_img_resize_dimensions', 10);
     }
     return $image;
 }
Esempio n. 5
0
function zem_rp_upload_articles($api_key)
{
    $media = array();
    foreach (zem_rp_get_all_attachments() as $image) {
        if (empty($media[$image->post_parent])) {
            $media[$image->post_parent] = array();
        }
        $meta = unserialize($image->meta);
        $media["{$image->post_parent}"][] = array("URL" => $image->guid, "width" => $meta['width'], "height" => $meta['height']);
    }
    $payload = array("found" => 0, "posts" => array());
    foreach (get_posts(array('numberposts' => 10000)) as $post) {
        $obj = array("ID" => $post->ID, "URL" => get_permalink($post->ID), "attachment_count" => 0, "attachments" => array(), "content" => $post->post_content, "date" => $post->post_date, "excerpt" => $post->post_excerpt, "featured_image" => "", "modified" => $post->post_modified, "post_thumbnail" => null, "slug" => $post->post_name, "status" => $post->post_status, "title" => $post->post_title, "type" => $post->post_type);
        if (has_post_thumbnail($post->ID)) {
            $thumb_id = get_post_thumbnail_id($post->ID);
            $meta = wp_get_attachment_metadata($thumb_id);
            $obj["post_thumbnail"] = array("URL" => wp_get_attachment_url($thumb_id), "width" => $meta["width"], "height" => $meta["height"]);
        }
        if (!empty($media[$post->ID])) {
            $obj["attachments"] = $media[$post->ID];
        }
        $obj["attachment_count"] = sizeof($obj["attachments"]);
        $payload["posts"][] = $obj;
    }
    $payload["found"] = sizeof($payload["posts"]);
    $payload["posts"] = $payload["posts"];
    $http_response = wp_remote_post(ZEM_RP_ZEMANTA_UPLOAD_URL, array("body" => array("payload" => json_encode($payload), "blog_name" => get_bloginfo('name'), "api_key" => $api_key, "feed_url" => get_bloginfo('rss2_url'), "blog_url" => get_bloginfo('url'), "platform" => 'wordpress-zem')));
    if (!is_wp_error($http_response) && wp_remote_retrieve_response_code($http_response) == 200) {
        $response = json_decode(wp_remote_retrieve_body($http_response));
        return $response->status === 'ok';
    }
    return false;
}
Esempio n. 6
0
 function thb_image_get_attachment_id($url)
 {
     $dir = wp_upload_dir();
     $dir = trailingslashit($dir['baseurl']);
     if (false === strpos($url, $dir)) {
         return false;
     }
     $file = basename($url);
     $query = array('post_type' => 'attachment', 'fields' => 'ids', 'meta_query' => array(array('value' => $file, 'compare' => 'LIKE')));
     $query['meta_query'][0]['key'] = '_wp_attached_file';
     $ids = get_posts($query);
     foreach ($ids as $id) {
         if ($url == array_shift(wp_get_attachment_image_src($id, 'full'))) {
             return $id;
         }
     }
     $query['meta_query'][0]['key'] = '_wp_attachment_metadata';
     $ids = get_posts($query);
     foreach ($ids as $id) {
         $meta = wp_get_attachment_metadata($id);
         foreach ($meta['sizes'] as $size => $values) {
             if ($values['file'] == $file && $url == array_shift(wp_get_attachment_image_src($id, $size))) {
                 return $id;
             }
         }
     }
     return false;
 }
Esempio n. 7
0
 function ut_delete_resized_images($post_id)
 {
     // Get attachment image metadata
     $metadata = wp_get_attachment_metadata($post_id);
     /* no meta found, let's leave */
     if (!$metadata) {
         return;
     }
     /* meta found but no image meta set */
     if (!isset($metadata['file']) || !isset($metadata['image_meta']['resized_images'])) {
         return;
     }
     $pathinfo = pathinfo($metadata['file']);
     $resized_images = $metadata['image_meta']['resized_images'];
     /* get Wordpress uploads directory (and bail if it doesn't exist) */
     $wp_upload_dir = wp_upload_dir();
     $upload_dir = $wp_upload_dir['basedir'];
     if (!is_dir($upload_dir)) {
         return;
     }
     /* Delete the resized images */
     foreach ($resized_images as $dims) {
         // Get the resized images filenames
         $file = $upload_dir . '/' . $pathinfo['dirname'] . '/' . $pathinfo['filename'] . '-' . $dims . '.' . $pathinfo['extension'];
         $file_retina = $upload_dir . '/' . $pathinfo['dirname'] . '/' . $pathinfo['filename'] . '-' . $dims . '@2x.' . $pathinfo['extension'];
         // Delete the resized image
         @unlink($file);
         @unlink($file_retina);
     }
 }
 /**
  * @ticket 32171
  */
 public function testImageEditOverwriteConstant()
 {
     define('IMAGE_EDIT_OVERWRITE', true);
     include_once ABSPATH . 'wp-admin/includes/image-edit.php';
     $filename = DIR_TESTDATA . '/images/canola.jpg';
     $contents = file_get_contents($filename);
     $upload = wp_upload_bits(basename($filename), null, $contents);
     $id = $this->_make_attachment($upload);
     $_REQUEST['action'] = 'image-editor';
     $_REQUEST['context'] = 'edit-attachment';
     $_REQUEST['postid'] = $id;
     $_REQUEST['target'] = 'all';
     $_REQUEST['do'] = 'save';
     $_REQUEST['history'] = '[{"c":{"x":5,"y":8,"w":289,"h":322}}]';
     $ret = wp_save_image($id);
     $media_meta = wp_get_attachment_metadata($id);
     $sizes1 = $media_meta['sizes'];
     $_REQUEST['history'] = '[{"c":{"x":5,"y":8,"w":189,"h":322}}]';
     $ret = wp_save_image($id);
     $media_meta = wp_get_attachment_metadata($id);
     $sizes2 = $media_meta['sizes'];
     $file_path = dirname(get_attached_file($id));
     foreach ($sizes1 as $key => $size) {
         if ($sizes2[$key]['file'] !== $size['file']) {
             $files_that_shouldnt_exist[] = $file_path . '/' . $size['file'];
         }
     }
     foreach ($files_that_shouldnt_exist as $file) {
         $this->assertFileNotExists($file, 'IMAGE_EDIT_OVERWRITE is leaving garbage image files behind.');
     }
 }
Esempio n. 9
0
function custom_logo_image()
{
    $logoID = get_field('logo', 'options');
    if ($logoID) {
        $meta = wp_get_attachment_metadata($logoID);
        ?>
		<style>
			body.login #login h1 a {
				background: url(<?php 
        echo esc_attr(wp_get_attachment_url($logoID));
        ?>
) no-repeat center top transparent;
				height: <?php 
        echo $meta['height'];
        ?>
px;
				width: <?php 
        echo $meta['width'];
        ?>
px;
				background-size: contain;
			}
		</style>
		<?php 
    }
}
 function get_template_variables($instance, $args)
 {
     static $player_id = 1;
     $poster = '';
     $video_host = $instance['host_type'];
     if ($video_host == 'self') {
         if (!empty($instance['video']['self_video'])) {
             // Handle an attachment video
             $src = wp_get_attachment_url($instance['video']['self_video']);
             $vid_info = wp_get_attachment_metadata($instance['video']['self_video']);
             $video_type = 'video/' . empty($vid_info['fileformat']) ? '' : $vid_info['fileformat'];
         } else {
             if (!empty($instance['video']['self_video_fallback'])) {
                 // Handle an external URL video
                 $src = $instance['video']['self_video_fallback'];
                 $vid_info = wp_check_filetype(basename($instance['video']['self_video_fallback']));
                 $video_type = $vid_info['type'];
             }
         }
         $poster = !empty($instance['video']['self_poster']) ? wp_get_attachment_url($instance['video']['self_poster']) : '';
     } else {
         $video_host = $this->get_host_from_url($instance['video']['external_video']);
         $video_type = 'video/' . $video_host;
         $src = !empty($instance['video']['external_video']) ? $instance['video']['external_video'] : '';
     }
     $return = array('player_id' => 'sow-player-' . $player_id++, 'host_type' => $instance['host_type'], 'src' => $src, 'video_type' => $video_type, 'is_skinnable_video_host' => $this->is_skinnable_video_host($video_host), 'poster' => $poster, 'autoplay' => !empty($instance['playback']['autoplay']), 'skin_class' => 'default');
     // Force oEmbed for this video
     if ($instance['host_type'] == 'external' && $instance['playback']['oembed']) {
         $return['is_skinnable_video_host'] = false;
     }
     return $return;
 }
Esempio n. 11
0
function mediatag_item_callback_show_meta($post_item, $size = 'medium')
{
    //	$image_src 	= wp_get_attachment_image_src($post_item->ID, $size);
    $media_meta = wp_get_attachment_metadata($post_item->ID);
    //	echo "media_meta<pre>"; print_r($media_meta); echo "</pre>";
    $image_meta = $media_meta['image_meta'];
    //print_r ($metadata);
    $meta_out = '';
    if ($image_meta['camera']) {
        $meta_out .= $image_meta['camera'] . ' ';
    }
    if ($image_meta['focal_length']) {
        $meta_out .= '@ ' . $image_meta['focal_length'] . ' mm ';
    }
    if ($image_meta['shutter_speed']) {
        $meta_out .= '- ¹/' . 1 / $image_meta['shutter_speed'] . ' sec';
    }
    if ($image_meta['aperture']) {
        $meta_out .= ', ƒ/' . $image_meta['aperture'] . ' ';
    }
    if ($image_meta['iso']) {
        $meta_out .= ', ISO ' . $image_meta['iso'] . ' ';
    }
    if ($image_meta['created_timestamp']) {
        $meta_out .= ' on ' . date('j F, Y', $image_meta['created_timestamp']) . ' ';
    }
    return $meta_out;
}
Esempio n. 12
0
function image_attachments($image_size = 'large', $width_min = 0, $height_min = 0)
{
    // Initialize images array; only fetch images for singular content, exit early and return an empty array otherwise
    $images = [];
    if (!is_singular()) {
        return $images;
    }
    global $post;
    // @TODO: use get_the_ID()
    // Override default image size; for reference, Facebook likes large images (1200 x 630 pixels) and Twitter likes smaller ones (less than 1 Mb)
    $image_size = apply_filters('ubik_seo_image_attachments_size', $image_size);
    // Are we are dealing with an actual image attachment page?
    if (wp_attachment_is_image()) {
        // Get all metadata (includes mime type) and image source in the usual way
        $attachment = wp_get_attachment_metadata($post->ID);
        $image_src = wp_get_attachment_image_src($post->ID, $image_size);
        // Is there an attachment of the desired size? Fill the mime type and appropriate height/width info
        if (!empty($attachment['sizes'][$image_size])) {
            $images[] = ['url' => $image_src[0], 'type' => $attachment['sizes'][$image_size]['mime-type'], 'width' => $attachment['sizes'][$image_size]['width'], 'height' => $attachment['sizes'][$image_size]['height']];
            // Otherwise fallback to the default image size
        } else {
            $images[] = ['url' => $image_src[0], 'type' => get_post_mime_type($post->ID), 'width' => $image_src[1], 'height' => $image_src[2]];
        }
        // All other posts, pages, etc.
    } else {
        // Featured image/post thumbnail first; Facebook prioritizes larger images so this might not have much of an effect
        if (has_post_thumbnail($post->ID)) {
            $image_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), $image_size);
            $images[] = ['url' => $image_src[0], 'type' => get_post_mime_type(get_post_thumbnail_id($post->ID)), 'width' => $image_src[1], 'height' => $image_src[2]];
        }
        // Get all images attachments sorted by date (oldest first)
        $attachments = get_children(['post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'posts_per_page' => apply_filters('ubik_seo_image_attachments_limit', 20), 'orderby' => 'date', 'order' => 'ASC']);
        // Cycle through all attachments and extract relevant image metadata
        if (count($attachments) >= 1) {
            foreach ($attachments as $attachment) {
                $image_src = wp_get_attachment_image_src($attachment->ID, $image_size);
                // Don't duplicate featured image
                if (has_post_thumbnail($post->ID)) {
                    if ($image_src[0] !== $images[0]['url']) {
                        $images[] = ['url' => $image_src[0], 'type' => get_post_mime_type(get_post_thumbnail_id($post->ID)), 'width' => $image_src[1], 'height' => $image_src[2]];
                    }
                } else {
                    $images[] = ['url' => $image_src[0], 'type' => get_post_mime_type($attachment->ID), 'width' => $image_src[1], 'height' => $image_src[2]];
                }
            }
        }
    }
    // Restrict output based on width and height requirements
    if ($images) {
        for ($i = 0; $i < count($images); $i++) {
            if ($images[$i]['width'] <= $width_min || $images[$i]['height'] <= $height_min) {
                unset($images[$i]);
            }
        }
    }
    // Re-index array (removes gaps)
    $images = array_values($images);
    // Return an array of image attachment metadata: url, type (mime type; optional), width, and height; usage e.g. $images[0]['url']
    return apply_filters('ubik_seo_image_attachments', $images);
}
Esempio n. 13
0
 public function get($type = "", $id = "", $size = "", $attr = array())
 {
     if (is_array($id) && $id["id"]) {
         $id = $id["id"];
     }
     if (!$id) {
         $id = get_post_thumbnail_id(get_the_ID());
     }
     if (!$id) {
         $id = get_field('image', get_the_ID());
         $id = $id["id"];
     }
     if (!$id) {
         $id = get_field('placeholder', 'options');
     }
     if (!$id) {
         return;
     }
     if ($type == "html") {
         return wp_get_attachment_image($id, $size);
     } else {
         if ($type == "url") {
             return reset(wp_get_attachment_image_src($id, $size));
         } else {
             if ($type == "") {
                 return wp_get_attachment_metadata($id);
             } else {
                 $res = wp_get_attachment_metadata($id);
                 return $res[$type];
             }
         }
     }
 }
Esempio n. 14
0
 /**
  * Retrieve resized image URL
  *
  * @param int $id Post ID or Attachment ID
  * @param int $width desired width of image (optional)
  * @param int $height desired height of image (optional)
  * @return string URL
  * @author Modern Tribe, Inc. (Peter Chester)
  */
 function get_image_url($id, $width = false, $height = false)
 {
     /**/
     // Get attachment and resize but return attachment path (needs to return url)
     $attachment = wp_get_attachment_metadata($id);
     $attachment_url = wp_get_attachment_url($id);
     if (isset($attachment_url)) {
         if ($width && $height) {
             $uploads = wp_upload_dir();
             $imgpath = $uploads['basedir'] . '/' . $attachment['file'];
             if (WP_DEBUG) {
                 error_log(__CLASS__ . '->' . __FUNCTION__ . '() $imgpath = ' . $imgpath);
             }
             $image = image_resize($imgpath, $width, $height);
             if ($image && !is_wp_error($image)) {
                 $image = path_join(dirname($attachment_url), basename($image));
             } else {
                 $image = $attachment_url;
             }
         } else {
             $image = $attachment_url;
         }
         if (isset($image)) {
             return $image;
         }
     }
 }
 /**
  * Callback for the "image_downsize" filter.
  *
  * @param bool $ignore A value meant to discard unfiltered info returned from this filter.
  * @param int $attachment_id The ID of the attachment for which we want a certain size.
  * @param string $size_name The name of the size desired.
  */
 public function filter_image_downsize($ignore = false, $attachment_id = 0, $size_name = 'thumbnail')
 {
     global $_wp_additional_image_sizes;
     $attachment_id = (int) $attachment_id;
     $size_name = trim($size_name);
     $meta = wp_get_attachment_metadata($attachment_id);
     /* the requested size does not yet exist for this attachment */
     if (empty($meta['sizes']) || empty($meta['sizes'][$size_name])) {
         // let's first see if this is a registered size
         if (isset($_wp_additional_image_sizes[$size_name])) {
             $height = (int) $_wp_additional_image_sizes[$size_name]['height'];
             $width = (int) $_wp_additional_image_sizes[$size_name]['width'];
             $crop = (bool) $_wp_additional_image_sizes[$size_name]['crop'];
             // if not, see if name is of form [width]x[height] and use that to crop
         } else {
             if (preg_match('#^(\\d+)x(\\d+)$#', $size_name, $matches)) {
                 $height = (int) $matches[2];
                 $width = (int) $matches[1];
                 $crop = true;
             }
         }
         if (!empty($height) && !empty($width)) {
             $resized_path = $this->_generate_attachment($attachment_id, $width, $height, $crop);
             $fullsize_url = wp_get_attachment_url($attachment_id);
             $file_name = basename($resized_path);
             $new_url = str_replace(basename($fullsize_url), $file_name, $fullsize_url);
             if (!empty($resized_path)) {
                 $meta['sizes'][$size_name] = array('file' => $file_name, 'width' => $width, 'height' => $height);
                 wp_update_attachment_metadata($attachment_id, $meta);
                 return array($new_url, $width, $height, true);
             }
         }
     }
     return false;
 }
 /**
  * Get attachment-specific data
  *
  * @param array $post
  * @return array
  */
 protected function prepare_post($post, $context = 'single')
 {
     $data = parent::prepare_post($post, $context);
     if (is_wp_error($data) || $post['post_type'] !== 'attachment') {
         return $data;
     }
     // $thumbnail_size = current_theme_supports( 'post-thumbnail' ) ? 'post-thumbnail' : 'thumbnail';
     $data['source'] = wp_get_attachment_url($post['ID']);
     $data['is_image'] = wp_attachment_is_image($post['ID']);
     $data['attachment_meta'] = wp_get_attachment_metadata($post['ID']);
     // Ensure empty meta is an empty object
     if (empty($data['attachment_meta'])) {
         $data['attachment_meta'] = new stdClass();
     } elseif (!empty($data['attachment_meta']['sizes'])) {
         $img_url_basename = wp_basename($data['source']);
         foreach ($data['attachment_meta']['sizes'] as $size => &$size_data) {
             // Use the same method image_downsize() does
             $size_data['url'] = str_replace($img_url_basename, $size_data['file'], $data['source']);
         }
     } else {
         $data['attachment_meta']['sizes'] = new stdClass();
     }
     // Override entity meta keys with the correct links
     $data['meta'] = array('links' => array('self' => json_url('/media/' . $post['ID']), 'author' => json_url('/users/' . $post['post_author']), 'collection' => json_url('/media'), 'replies' => json_url('/media/' . $post['ID'] . '/comments'), 'version-history' => json_url('/media/' . $post['ID'] . '/revisions')));
     if (!empty($post['post_parent'])) {
         $data['meta']['links']['up'] = json_url('/media/' . (int) $post['post_parent']);
     }
     return apply_filters('json_prepare_attachment', $data, $post, $context);
 }
Esempio n. 17
0
 public function __construct($controller)
 {
     $this->ctrl = $controller;
     //init the option if needed
     if (!isset($_SESSION["wp-short-pixel-priorityQueue"])) {
         //take the priority list from the options (we persist there the priority IDs from the previous session)
         $prioQueueOpt = WPShortPixel::getOpt('wp-short-pixel-priorityQueue', array());
         //here we save the IDs for the files that need to be processed after an image upload for example
         $_SESSION["wp-short-pixel-priorityQueue"] = array();
         foreach ($prioQueueOpt as $ID) {
             $meta = wp_get_attachment_metadata($ID);
             WPShortPixel::log("INIT: Item {$ID} from options has metadata: " . json_encode($meta));
             if (!isset($meta['ShortPixelImprovement'])) {
                 $this->push($ID);
             }
         }
         update_option('wp-short-pixel-priorityQueue', $_SESSION["wp-short-pixel-priorityQueue"]);
         WPShortPixel::log("INIT: Session queue not found, updated from Options with " . json_encode($_SESSION["wp-short-pixel-priorityQueue"]));
     }
     $this->startBulkId = WPShortPixel::getOpt('wp-short-pixel-query-id-start', 0);
     //current query ID used for postmeta queries
     $this->stopBulkId = WPShortPixel::getOpt('wp-short-pixel-query-id-stop', 0);
     //min ID used for postmeta queries
     $this->bulkCount = WPShortPixel::getOpt("wp-short-pixel-bulk-count", 0);
     $this->bulkPreviousPercent = WPShortPixel::getOpt("wp-short-pixel-bulk-previous-percent", 0);
     $this->bulkCurrentlyProcessed = WPShortPixel::getOpt("wp-short-pixel-bulk-processed-items", 0);
     $this->bulkAlreadyDoneCount = WPShortPixel::getOpt("wp-short-pixel-bulk-done-count", 0);
     $this->lastBulkStartTime = WPShortPixel::getOpt('wp-short-pixel-last-bulk-start-time', 0);
     //time of the last start of the bulk.
     $this->lastBulkSuccessTime = WPShortPixel::getOpt('wp-short-pixel-last-bulk-success-time', 0);
     //time of the last start of the bulk.
     $this->bulkRunningTime = WPShortPixel::getOpt('wp-short-pixel-bulk-running-time', 0);
     //how long the bulk ran that far.
 }
Esempio n. 18
0
 function gabfire_call_post_thumb($parameters)
 {
     /* Get default Post Thumbnail of WordPress */
     global $post;
     $image_id = get_post_thumbnail_id();
     $image_url = wp_get_attachment_image_src($image_id, $parameters['name']);
     $image_url = $image_url[0];
     $image_meta = wp_get_attachment_metadata($image_id);
     //error_log(serialize($image_meta));
     $alt_text = get_post_meta($image_id, '_wp_attachment_image_alt', true);
     if (!empty($alt_text)) {
         $title = $alt_text;
     } else {
         $title = get_the_title();
     }
     if ($parameters['link'] == 1) {
         echo "<a href='" . get_permalink() . "' rel='bookmark'>";
     }
     if ($parameters['imgtag'] == 1) {
         echo "<img src='";
         //echo "<img width='".$image_meta['sizes'][$parameters['name']]['width']."' height='".$image_meta['sizes'][$parameters['name']]['height']."' src='";
     }
     echo $image_url;
     if ($parameters['imgtag'] == 1) {
         echo "' class='" . $parameters['thumb_align'] . "' alt='" . get_the_title() . "' title='" . $title . "' />";
     }
     if ($parameters['link'] == 1) {
         echo "</a>";
     }
 }
 /**
  * Get the photos belonging to an album
  *
  * @param $album_id
  *
  * @return array
  */
 public function get_photos($album_id)
 {
     $media = get_post_meta($album_id, '_apg_album_items', true);
     $stored_value = get_post_meta($album_id, 'apg_photo_order', true);
     $images = array();
     if (!isset($media['photos'])) {
         return array();
     }
     if (isset($stored_value) && !empty($stored_value)) {
         $photo_index = array_flip($this->arrayColumn($media['photos'], 'id'));
         $stored_value = explode(',', $stored_value);
         foreach ($stored_value as $item) {
             if (empty($item) || !isset($photo_index[$item])) {
                 continue;
             }
             $key_id = $photo_index[$item];
             $images[] = array('ID' => $media['photos'][$key_id]['id'], 'metadata' => wp_get_attachment_metadata($media['photos'][$key_id]['id']));
             unset($media['photos'][$key_id]);
         }
     } else {
         foreach ($media['photos'] as $item) {
             $images[] = array('ID' => $item['id'], 'metadata' => wp_get_attachment_metadata($item['id']));
         }
     }
     return $images;
 }
Esempio n. 20
0
function wr2x_manage_media_custom_column($column_name, $id)
{
    if ($column_name != 'Retina') {
        return;
    }
    if (wr2x_is_ignore($id)) {
        echo "<img style='margin-top: -2px; margin-bottom: 2px; width: 16px; height: 16px;' src='" . trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-retina-2x/img') . "tick-circle.png' />";
        return;
    }
    // Check if the attachment is an image
    $meta = wp_get_attachment_metadata($id);
    if (!($meta && isset($meta['width']) && isset($meta['height']))) {
        return;
    }
    $isAlright = true;
    $info = wr2x_retina_info($id);
    foreach ($info as $name => $attr) {
        if ($attr == 'PENDING' || is_array($attr)) {
            $isAlright = false;
        }
    }
    // Displays the result
    echo "<p id='wr2x_attachment_{$id}' style='margin-bottom: 2px;'>";
    if ($isAlright) {
        echo "<img style='margin-top: -2px; margin-bottom: 2px; width: 16px; height: 16px;' src='" . trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-retina-2x/img') . "tick-circle.png' />";
    } else {
        echo "<a href='upload.php?page=wp-retina-2x'><img style='margin-top: -2px; margin-bottom: 2px; width: 16px; height: 16px;' src='" . trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-retina-2x/img') . "exclamation.png' /></a>";
    }
    echo "</p>";
}
Esempio n. 21
0
function post_image_sizes($postID)
{
    $img_meta = wp_get_attachment_metadata(get_post_thumbnail_id($postID));
    foreach ($img_meta['sizes'] as $key => $value) {
        echo " data-image-" . $key . '="' . MEDIA_DIR . $value["file"] . '"';
    }
}
function wr2x_manage_media_custom_column($column_name, $id)
{
    if ($column_name != 'Retina') {
        return;
    }
    if (wr2x_is_ignore($id)) {
        echo "<img style='margin-top: -2px; margin-bottom: 2px; width: 16px; height: 16px;' src='" . plugin_dir_url(__FILE__) . "img/tick-circle.png' />";
        return;
    }
    // Check if the attachment is an image
    $meta = wp_get_attachment_metadata($id);
    if (!wr2x_is_image_meta($meta)) {
        return "";
    }
    $isAlright = true;
    $info = wr2x_retina_info($id);
    foreach ($info as $name => $attr) {
        if ($attr == 'PENDING' || is_array($attr)) {
            $isAlright = false;
        }
    }
    // Displays the result
    echo "<p id='wr2x_attachment_{$id}' style='margin-bottom: 2px;'>";
    if ($isAlright) {
        echo "<img style='margin-top: -2px; margin-bottom: 2px; width: 16px; height: 16px;' src='" . plugin_dir_url(__FILE__) . "img/tick-circle.png' />";
    } else {
        echo "<a href='upload.php?page=wp-retina-2x'><img style='margin-top: -2px; margin-bottom: 2px; width: 16px; height: 16px;' src='" . plugin_dir_url(__FILE__) . "img/exclamation.png' /></a>";
    }
    echo "</p>";
}
 function audioselect_settings_field($settings, $value)
 {
     global $VISUAL_COMPOSER_EXTENSIONS;
     $dependency = vc_generate_dependencies_attributes($settings);
     $param_name = isset($settings['param_name']) ? $settings['param_name'] : '';
     $type = isset($settings['type']) ? $settings['type'] : '';
     $audio_format = isset($settings['audio_format']) ? $settings['audio_format'] : 'mpeg';
     $audio_format = explode(',', $audio_format);
     $url = $VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_PluginPath;
     $output = '';
     $args = array('post_type' => 'attachment', 'post_mime_type' => 'audio', 'post_status' => 'inherit', 'posts_per_page' => -1);
     if ($value != '') {
         $metadata = wp_get_attachment_metadata($value);
         $disabled = '';
         $visible = 'display: block;';
         $query_audios = new WP_Query($args);
         if ($query_audios->have_posts()) {
             foreach ($query_audios->posts as $audio) {
                 if ($audio->ID == $value) {
                     $audio_id = $value;
                     $audio_title = $audio->post_title;
                     $audio_length = isset($metadata['length_formatted']) ? $metadata['length_formatted'] : 'N/A';
                     break;
                 }
             }
         }
         wp_reset_postdata();
     } else {
         $metadata = array();
         $disabled = 'disabled="disabled"';
         $visible = 'display: none;';
         $audio_id = '';
         $audio_title = '';
         $audio_url = '';
         $audio_length = '';
     }
     $output .= '<div class="ts_vcsc_audio_select_block" data-format="' . implode(',', $audio_format) . '">';
     $output .= '<input style="display: none;" name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-textinput audio_value ' . $param_name . ' ' . $type . '_field" type="text" value="' . $value . '" ' . $dependency . '/>';
     $output .= '<input type="button" class="audio_select button" value="' . __('Select Audio', 'ts_visual_composer_extend') . '" style="width: 150px; text-align: center;">';
     $output .= '<input type="button" class="audio_remove button" value="' . __('Remove Audio', 'ts_visual_composer_extend') . '" style="width: 150px; text-align: center; color: red; margin-left: 20px;" ' . $disabled . '>';
     $output .= '<div class="audio_metadata_frame" style="width: 100%; margin-top: 20px; ' . $visible . '">';
     $output .= '<div style="float: left; width: 92px; margin-right: 10px;">';
     if (in_array("mp3", $audio_format) || in_array("mpeg", $audio_format)) {
         $output .= '<img src="' . TS_VCSC_GetResourceURL('images/mediatypes/mp3_audio.jpg') . '" style="width: 90px; height: auto; border: 1px solid #ededed;">';
     } else {
         if (in_array("ogg", $audio_format) || in_array("ogv", $audio_format)) {
             $output .= '<img src="' . TS_VCSC_GetResourceURL('images/mediatypes/ogg_audio.jpg') . '" style="width: 90px; height: auto; border: 1px solid #ededed;">';
         }
     }
     $output .= '</div>';
     $output .= '<div style="float: left;">';
     $output .= '<div style=""><span style="">' . __('Audio ID', 'ts_visual_composer_extend') . ': </span><span class="audio_metadata audio_id">' . $audio_id . '</span></div>';
     $output .= '<div style=""><span style="">' . __('Audio Name', 'ts_visual_composer_extend') . ': </span><span class="audio_metadata audio_name">' . $audio_title . '</span></div>';
     $output .= '<div style=""><span style="">' . __('Audio Duration', 'ts_visual_composer_extend') . ': </span><span class="audio_metadata audio_duration">' . ($audio_length != '' ? $audio_length : 'N/A') . '</span></div>';
     $output .= '</div>';
     $output .= '</div>';
     $output .= '</div>';
     return $output;
 }
Esempio n. 24
0
function featured_image($post)
{
    if (has_post_thumbnail($post->ID)) {
        $featured_img = wp_get_attachment_metadata(get_post_thumbnail_id($post->ID));
        print_r($featured_img);
        echo '<img src="img/graphics/nypl-case-study.jpg" alt="NYPL">';
    }
}
 function get_meta($data, $options = array())
 {
     $meta = wp_get_attachment_metadata($data->ID);
     if (isset($meta['image_meta'])) {
         return $meta['image_meta'];
     }
     return null;
 }
 function setUp()
 {
     $this->attachment = create_attachment();
     $this->image_data = wp_get_attachment_metadata($this->attachment);
     $this->upload_url = wp_upload_dir()['baseurl'];
     $this->image = '<img src="' . $this->upload_url . '/' . $this->image_data['file'] . '" class="alignnone">';
     add_filter('rwp_edit_attributes', array($this, 'edit_attributes'));
 }
function insert_exif()
{
    if (is_single() && in_category('118') || is_attachment()) {
        global $post;
        $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID);
        $attachments = get_posts($args);
        foreach ($attachments as $attachment) {
            $imgid = $attachment->ID;
            $imgmeta = wp_get_attachment_metadata($imgid);
            $latitude = $imgmeta['image_meta']['latitude'];
            $longitude = $imgmeta['image_meta']['longitude'];
            $lat_ref = $imgmeta['image_meta']['latitude_ref'];
            $lng_ref = $imgmeta['image_meta']['longitude_ref'];
            $lat = geo_single_fracs2dec($latitude);
            $lng = geo_single_fracs2dec($longitude);
            if ($lat_ref == 'S') {
                $neg_lat = '-';
            } else {
                $neg_lat = '';
            }
            if ($lng_ref == 'W') {
                $neg_lng = '-';
            } else {
                $neg_lng = '';
            }
            echo "<ul class='exif'>";
            if (!empty($imgmeta['image_meta']['aperture'])) {
                echo "<li>Aperture: f/" . $imgmeta['image_meta']['aperture'] . "</li>";
            }
            if (!empty($imgmeta['image_meta']['iso'])) {
                echo "<li>ISO: " . $imgmeta['image_meta']['iso'] . "</li>";
            }
            if (!empty($imgmeta['image_meta']['shutter_speed'])) {
                echo "<li>Shutter Speed: ";
                if (1 / $imgmeta['image_meta']['shutter_speed'] > 1) {
                    echo "1/";
                    if (number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1) == 1.3 or number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1) == 1.5 or number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1) == 1.6 or number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1) == 2.5) {
                        echo number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1, '.', '') . " s</li>";
                    } else {
                        echo number_format(1 / $imgmeta['image_meta']['shutter_speed'], 0, '.', '') . " s</li>";
                    }
                } else {
                    echo $imgmeta['image_meta']['shutter_speed'] . " s</li>";
                }
            }
            if (!empty($imgmeta['image_meta']['focal_length'])) {
                echo "<li>Focal Length: " . $imgmeta['image_meta']['focal_length'] . "mm</li>";
            }
            if (!empty($imgmeta['image_meta']['camera'])) {
                echo "<li>Camera: " . $imgmeta['image_meta']['camera'] . "</li>";
            }
            if ($latitude != 0 && $longitude != 0) {
                echo '<li>Location: <a href="http://maps.google.com/maps?q=' . $neg_lat . number_format($lat, 6) . '+' . $neg_lng . number_format($lng, 6) . '&z=11">' . geo_pretty_fracs2dec($latitude) . $lat_ref . ' ' . geo_pretty_fracs2dec($longitude) . $lng_ref . '</a></li>';
            }
            echo "</ul>";
        }
    }
}
Esempio n. 28
0
 /**
  * Resize images dynamically using wp built in functions
  *
  * @param string $img_url
  * @param int $width
  * @param int $height
  * @param bool $crop
  * @return array
  */
 function themify_do_img($img_url = null, $width, $height, $crop = false)
 {
     $img_url = esc_url($img_url);
     $upload_dir = wp_upload_dir();
     $base_url = $upload_dir['baseurl'];
     // Check if the image is an attachment. If it's external return url, width and height.
     if (substr($img_url, -strlen($base_url)) === $base_url) {
         return array('url' => $img_url, 'width' => $width, 'height' => $height);
     }
     // Get post's attachment meta data to look for references to the requested image size
     $attachment_id = themify_get_attachment_id_from_url($img_url, $base_url);
     // If no relationship between a post and a image size was found, return url, width and height.
     if (!$attachment_id) {
         return array('url' => $img_url, 'width' => $width, 'height' => $height);
     }
     // Fetch attachment meta data. Up to this point we know the attachment ID is valid.
     $meta = wp_get_attachment_metadata($attachment_id);
     // Go through the attachment meta data sizes looking for an image size match.
     if (is_array($meta) && isset($meta['sizes']) && is_array($meta['sizes'])) {
         // Perform calculations when height = 0
         if (is_null($height) || 0 === $height || '0' === $height) {
             // If width and height or original image are available as metadata
             if (isset($meta['width']) && isset($meta['height'])) {
                 // Divide width by original image aspect ratio to obtain projected height
                 // The floor function is used so it returns an int and metadata can be written
                 $height = floor($width / ($meta['width'] / $meta['height']));
             } else {
                 $height = 0;
             }
         }
         foreach ($meta['sizes'] as $key => $size) {
             if ($size['width'] == $width && $size['height'] == $height) {
                 setlocale(LC_CTYPE, get_locale() . '.UTF-8');
                 return array('url' => str_replace(basename($img_url), $size['file'], $img_url), 'width' => $width, 'height' => $height, 'attachment_id' => $attachment_id);
             }
         }
     } elseif (is_array($meta) && (!isset($meta['sizes']) || !is_array($meta['sizes']))) {
         // If the meta is an array, but doesn't have the 'sizes' element or if it has it, it's not an array,
         // return original image since there's something wrong with this attachment meta data: it exists,
         // but its format is not correct.
         return array('url' => $img_url, 'width' => $width, 'height' => $height, 'attachment_id' => $attachment_id);
     }
     // Requested image size doesn't exists, so let's create one
     if (true == $crop) {
         add_filter('image_resize_dimensions', 'themify_img_resize_dimensions', 10, 5);
     }
     // Patch meta because if we're here, there's a valid attachment ID for sure, but maybe the meta data is not ok.
     if (!is_array($meta) && empty($meta)) {
         $meta['sizes'] = array('large' => array());
     }
     // Generate image returning an array with image url, width and height. If image can't generated, original url, width and height are used.
     $image = themify_make_image_size($attachment_id, $width, $height, $meta, $img_url);
     if (true == $crop) {
         remove_filter('image_resize_dimensions', 'themify_img_resize_dimensions', 10);
     }
     $image['attachment_id'] = $attachment_id;
     return $image;
 }
 function downsize($out, $id, $size)
 {
     $img_url = wp_get_attachment_url($id);
     $img_path = get_attached_file($id);
     $meta = wp_get_attachment_metadata($id);
     $width = $height = 0;
     $is_intermediate = false;
     $img_url_basename = wp_basename($img_url);
     $img_path_basename = wp_basename($img_path);
     // extract filter from size request
     if (!is_string($size)) {
         return $out;
     }
     $size_bits = explode(':', $size);
     $filter = isset($size_bits[1]) ? $size_bits[1] : false;
     $size = isset($size_bits[0]) ? $size_bits[0] : false;
     // start the reactor
     if ($filter) {
         // try for a new style intermediate size
         if ($intermediate = image_get_intermediate_size($id, $size)) {
             $img_url = str_replace($img_url_basename, $intermediate['file'], $img_url);
             $img_path = str_replace($img_path_basename, $intermediate['file'], $img_path);
             $width = $intermediate['width'];
             $height = $intermediate['height'];
             $is_intermediate = true;
         } elseif ($size == 'thumbnail') {
             // fall back to the old thumbnail
             if (($thumb_file = wp_get_attachment_thumb_file($id)) && ($info = getimagesize($thumb_file))) {
                 $img_url = str_replace($img_url_basename, wp_basename($thumb_file), $img_url);
                 $img_path = str_replace($img_path_basename, wp_basename($thumb_file), $img_path);
                 $width = $info[0];
                 $height = $info[1];
                 $is_intermediate = true;
             }
         }
         if (!$width && !$height && isset($meta['width'], $meta['height'])) {
             // any other type: use the real image
             $width = $meta['width'];
             $height = $meta['height'];
         }
         if ($img_url && $img_path) {
             $input = $img_path;
             $output = $this->filtered_url($input, $filter);
             // generate filtered thumb
             if (!file_exists($output)) {
                 $this->filter($filter, $input, $output);
             }
             // point to our new file
             $img_url = $this->filtered_url($img_url, $filter);
             // we have the actual image size, but might need to further constrain it if content_width is narrower
             list($width, $height) = image_constrain_size_for_editor($width, $height, $size);
             return array($img_url, $width, $height, $is_intermediate);
         }
         // don't continue the downsize funtion
         return true;
     }
     return $out;
 }
function image_keyword_tagger_add_keywords($mid, $object_id, $meta_key, $_meta_value)
{
    if ('_wp_attachment_metadata' == $meta_key) {
        $attachment_meta = wp_get_attachment_metadata($object_id);
        if (!empty($attachment_meta['image_meta']['keywords'])) {
            wp_set_post_tags($object_id, implode(',', $attachment_meta['image_meta']['keywords']), true);
        }
    }
}