function ewww_manage_image_custom_column($column_name, $id)
 {
     // once we've found our custom column
     if ($column_name == 'ewww_image_optimizer') {
         // get the metadata for the image
         $meta = new nggMeta($id);
         // get the optimization status for the image
         $status = $meta->get_META('ewww_image_optimizer');
         $msg = '';
         // get the file path of the image
         $file_path = $meta->image->imagePath;
         // get the mimetype of the image
         $type = ewww_image_optimizer_mimetype($file_path, 'i');
         // retrieve the human-readable filesize of the image
         $file_size = size_format(ewww_image_optimizer_filesize($file_path), 2);
         $file_size = str_replace('B ', 'B', $file_size);
         //$file_size = ewww_image_optimizer_format_bytes(filesize($file_path));
         $valid = true;
         // check to see if we have a tool to handle the mimetype detected
         switch ($type) {
             case 'image/jpeg':
                 // if jpegtran is missing, tell the user
                 if (!EWWW_IMAGE_OPTIMIZER_JPEGTRAN && !ewww_image_optimizer_get_option('ewww_image_optimizer_cloud_jpg')) {
                     $valid = false;
                     $msg = '<br>' . sprintf(__('%s is missing', EWWW_IMAGE_OPTIMIZER_DOMAIN), '<em>jpegtran</em>');
                 }
                 break;
             case 'image/png':
                 // if the PNG tools are missing, tell the user
                 if (!EWWW_IMAGE_OPTIMIZER_PNGOUT && !EWWW_IMAGE_OPTIMIZER_OPTIPNG && !ewww_image_optimizer_get_option('ewww_image_optimizer_cloud_png')) {
                     $valid = false;
                     $msg = '<br>' . sprintf(__('%s is missing', EWWW_IMAGE_OPTIMIZER_DOMAIN), '<em>optipng/pngout</em>');
                 }
                 break;
             case 'image/gif':
                 // if gifsicle is missing, tell the user
                 if (!EWWW_IMAGE_OPTIMIZER_GIFSICLE && !ewww_image_optimizer_get_option('ewww_image_optimizer_cloud_gif')) {
                     $valid = false;
                     $msg = '<br>' . sprintf(__('%s is missing', EWWW_IMAGE_OPTIMIZER_DOMAIN), '<em>gifsicle</em>');
                 }
                 break;
             default:
                 $valid = false;
         }
         // file isn't in a format we can work with, we don't work with strangers
         if ($valid == false) {
             print __('Unsupported file type', EWWW_IMAGE_OPTIMIZER_DOMAIN) . $msg;
             return;
         }
         // if we have a valid status, display it, the image size, and give a re-optimize link
         if ($status && !empty($status)) {
             echo $status;
             echo "<br>" . sprintf(__('Image Size: %s', EWWW_IMAGE_OPTIMIZER_DOMAIN), $file_size);
             printf("<br><a href=\"admin.php?action=ewww_ngg_manual&amp;ewww_force=1&amp;ewww_attachment_ID=%d\">%s</a>", $id, __('Re-optimize', EWWW_IMAGE_OPTIMIZER_DOMAIN));
             // otherwise, give the image size, and a link to optimize right now
         } else {
             _e('Not processed', EWWW_IMAGE_OPTIMIZER_DOMAIN);
             echo "<br>" . sprintf(__('Image Size: %s', EWWW_IMAGE_OPTIMIZER_DOMAIN), $file_size);
             printf("<br><a href=\"admin.php?action=ewww_ngg_manual&amp;ewww_attachment_ID=%d\">%s</a>", $id, __('Optimize now!', EWWW_IMAGE_OPTIMIZER_DOMAIN));
         }
     }
 }
Exemple #2
0
<?php

// look up for the path
require_once dirname(dirname(__FILE__)) . '/ngg-config.php';
require_once NGGALLERY_ABSPATH . '/lib/meta.php';
require_once NGGALLERY_ABSPATH . '/lib/image.php';
if (!is_user_logged_in()) {
    die(__('Cheatin&#8217; uh?'));
}
if (!current_user_can('NextGEN Manage gallery')) {
    die(__('Cheatin&#8217; uh?'));
}
global $wpdb;
$id = (int) $_GET['id'];
// let's get the meta data'
$meta = new nggMeta($id);
$dbdata = $meta->get_saved_meta();
$exifdata = $meta->get_EXIF();
$iptcdata = $meta->get_IPTC();
$xmpdata = $meta->get_XMP();
?>
	<!-- META DATA -->
	<fieldset class="options nggallery">
	<h3><?php 
_e('Meta Data', 'nggallery');
?>
</h3>
	<?php 
if ($dbdata) {
    ?>
		<table id="the-list-x" width="100%" cellspacing="3" cellpadding="3">
Exemple #3
0
/**
 * nggSinglePicture() - show a single picture based on the id
 * 
 * @access public 
 * @param int $imageID, db-ID of the image
 * @param int (optional) $width, width of the image
 * @param int (optional) $height, height of the image
 * @param string $mode (optional) could be none, watermark, web20
 * @param string $float (optional) could be none, left, right
 * @param string $template (optional) name for a template file, look for singlepic-$template
 * @param string $caption (optional) additional caption text
 * @param string $link (optional) link to a other url instead the full image
 * @return the content
 */
function nggSinglePicture($imageID, $width = 250, $height = 250, $mode = '', $float = '', $template = '', $caption = '', $link = '')
{
    global $post;
    $ngg_options = nggGallery::get_option('ngg_options');
    // get picturedata
    $picture = nggdb::find_image($imageID);
    // if we didn't get some data, exit now
    if ($picture == null) {
        return __('[SinglePic not found]', 'nggallery');
    }
    // add float to img
    switch ($float) {
        case 'left':
            $float = ' ngg-left';
            break;
        case 'right':
            $float = ' ngg-right';
            break;
        case 'center':
            $float = ' ngg-center';
            break;
        default:
            $float = '';
            break;
    }
    // clean mode if needed
    $mode = preg_match('/(web20|watermark)/i', $mode) ? $mode : '';
    //let's initiate the url
    $picture->thumbnailURL = false;
    // check fo cached picture
    if ($post->post_status == 'publish') {
        $picture->thumbnailURL = $picture->cached_singlepic_file($width, $height, $mode);
    }
    // if we didn't use a cached image then we take the on-the-fly mode
    if (!$picture->thumbnailURL) {
        $picture->thumbnailURL = trailingslashit(home_url()) . 'index.php?callback=image&amp;pid=' . $imageID . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;mode=' . $mode;
    }
    // add more variables for render output
    $picture->imageURL = empty($link) ? $picture->imageURL : $link;
    $picture->href_link = $picture->get_href_link();
    $picture->alttext = html_entity_decode(stripslashes(nggGallery::i18n($picture->alttext, 'pic_' . $picture->pid . '_alttext')));
    $picture->linktitle = htmlspecialchars(stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')));
    $picture->description = html_entity_decode(stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')));
    $picture->classname = 'ngg-singlepic' . $float;
    $picture->thumbcode = $picture->get_thumbcode('singlepic' . $imageID);
    $picture->height = (int) $height;
    $picture->width = (int) $width;
    $picture->caption = nggGallery::i18n($caption);
    // filter to add custom content for the output
    $picture = apply_filters('ngg_image_object', $picture, $imageID);
    // let's get the meta data
    $meta = new nggMeta($imageID);
    $meta->sanitize();
    $exif = $meta->get_EXIF();
    $iptc = $meta->get_IPTC();
    $xmp = $meta->get_XMP();
    $db = $meta->get_saved_meta();
    //if we get no exif information we try the database
    $exif = $exif == false ? $db : $exif;
    // look for singlepic-$template.php or pure singlepic.php
    $filename = empty($template) ? 'singlepic' : 'singlepic-' . $template;
    // create the output
    $out = nggGallery::capture($filename, array('image' => $picture, 'meta' => $meta, 'exif' => $exif, 'iptc' => $iptc, 'xmp' => $xmp, 'db' => $db));
    $out = apply_filters('ngg_show_singlepic_content', $out, $picture);
    return $out;
}
Exemple #4
0
/**
 * ngg_import_date_time() - Read the timestamp from exif and insert it into the database
 * 
 * @return void
 */
function ngg_import_date_time()
{
    global $wpdb;
    $imagelist = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->nggallery} AS t INNER JOIN {$wpdb->nggpictures} AS tt ON t.gid = tt.galleryid ORDER BY tt.pid ASC");
    if (is_array($imagelist)) {
        foreach ($imagelist as $image) {
            $picture = new nggImage($image);
            $meta = new nggMeta($picture->imagePath, true);
            $date = $meta->get_date_time();
            $wpdb->query("UPDATE {$wpdb->nggpictures} SET imagedate = '{$date}' WHERE pid = '{$picture->pid}'");
        }
    }
}
Exemple #5
0
 /**
  * Maybe import some meta data to the database. The functions checks the flag 'saved'
  * and if based on compat reason (pre V1.4.0) we save then some meta datas to the database
  * 
  * @since V1.4.0
  * @param int $id
  * @return result
  */
 function maybe_import_meta($id)
 {
     require_once NGGALLERY_ABSPATH . '/lib/meta.php';
     $meta_obj = new nggMeta($id);
     if ($meta_obj->image->meta_data['saved'] != true) {
         $common = $meta_obj->get_common_meta();
         //this flag will inform us that the import is already one time performed
         $common['saved'] = true;
         $result = nggdb::update_image_meta($id, $common);
     } else {
         return false;
     }
     return $result;
 }
	function ewww_manage_image_custom_column( $column_name, $id ) {
		// once we've found our custom column
		if( $column_name == 'ewww_image_optimizer' ) {    
			// get the metadata for the image
			$meta = new nggMeta( $id );
			// get the optimization status for the image
			$status = $meta->get_META( 'ewww_image_optimizer' );
			$msg = '';
			// get the file path of the image
			$file_path = $meta->image->imagePath;
			// get the mimetype of the image
			$type = ewww_image_optimizer_mimetype($file_path, 'i');
			// retrieve the human-readable filesize of the image
			$file_size = size_format( ewww_image_optimizer_filesize( $file_path ), 2 );
			$file_size = str_replace( 'B ', 'B', $file_size );
			$valid = true;
			// check to see if we have a tool to handle the mimetype detected
			$skip = ewww_image_optimizer_skip_tools();
	                switch ( $type ) {
        	                case 'image/jpeg':
					// if jpegtran is missing, tell the user
					if( ! EWWW_IMAGE_OPTIMIZER_JPEGTRAN && ! $skip['jpegtran'] ) {
                        	                $valid = false;
	     	                                $msg = '<br>' . wp_kses( sprintf(__('%s is missing', EWWW_IMAGE_OPTIMIZER_DOMAIN), '<em>jpegtran</em>'), array( 'em' => array() ) );
	                                }
					break;
				case 'image/png':
					// if the PNG tools are missing, tell the user
					if( ! EWWW_IMAGE_OPTIMIZER_PNGOUT && ! EWWW_IMAGE_OPTIMIZER_OPTIPNG && ! $skip['optipng'] && ! $skip['pngout'] ) {
						$valid = false;
						$msg = '<br>' . wp_kses( sprintf(__('%s is missing', EWWW_IMAGE_OPTIMIZER_DOMAIN), '<em>optipng/pngout</em>'), array( 'em' => array() ) );
					}
					break;
				case 'image/gif':
					// if gifsicle is missing, tell the user
					if( ! EWWW_IMAGE_OPTIMIZER_GIFSICLE && ! $skip['gifsicle'] ) {
						$valid = false;
						$msg = '<br>' . wp_kses( sprintf(__('%s is missing', EWWW_IMAGE_OPTIMIZER_DOMAIN), '<em>gifsicle</em>'), array( 'em' => array() ) );
					}
					break;
				default:
					$valid = false;
			}
			// file isn't in a format we can work with, we don't work with strangers
			if ( $valid == false ) {
				echo esc_html__( 'Unsupported file type', EWWW_IMAGE_OPTIMIZER_DOMAIN ) . $msg;
				return;
			}
			$ewww_manual_nonce = wp_create_nonce( "ewww-manual-" . $id );
			// if we have a valid status, display it, the image size, and give a re-optimize link
			if ( ! empty ( $status ) ) {
				echo esc_html( $status );
				echo "<br>" . sprintf(esc_html__('Image Size: %s', EWWW_IMAGE_OPTIMIZER_DOMAIN), $file_size);
				if ( current_user_can( apply_filters( 'ewww_image_optimizer_manual_permissions', '' ) ) )  {
					printf("<br><a href=\"admin.php?action=ewww_ngg_manual&amp;ewww_manual_nonce=$ewww_manual_nonce&amp;ewww_force=1&amp;ewww_attachment_ID=%d\">%s</a>",
						$id,
						esc_html__('Re-optimize', EWWW_IMAGE_OPTIMIZER_DOMAIN));
				}
			} elseif ( get_transient( 'ewwwio-background-in-progress-ngg-' . $id ) ) {
				esc_html_e( 'In Progress', EWWW_IMAGE_OPTIMIZER_DOMAIN );
			// otherwise, give the image size, and a link to optimize right now
			} else {
				esc_html_e('Not processed', EWWW_IMAGE_OPTIMIZER_DOMAIN);
				echo "<br>" . sprintf(esc_html__('Image Size: %s', EWWW_IMAGE_OPTIMIZER_DOMAIN), $file_size);
				if ( current_user_can( apply_filters( 'ewww_image_optimizer_manual_permissions', '' ) ) )  {
					printf("<br><a href=\"admin.php?action=ewww_ngg_manual&amp;ewww_manual_nonce=$ewww_manual_nonce&amp;ewww_attachment_ID=%d\">%s</a>",
						$id,
						esc_html__('Optimize now!', EWWW_IMAGE_OPTIMIZER_DOMAIN));
				}
			}
		}
	}
 public function handleUpload_widget()
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/class.npu_uploader.php';
     require_once NGGALLERY_ABSPATH . '/lib/meta.php';
     $ngg->options['swfupload'] = false;
     //Where is this being instantiated?
     if (isset($_POST['uploadimage_widget'])) {
         check_admin_referer('ngg_addgallery');
         if (!isset($_FILES['MF__F_0_0']['error']) || $_FILES['MF__F_0_0']['error'] == 0) {
             $objUploaderNggAdmin = new UploaderNggAdmin();
             $messagetext = $objUploaderNggAdmin->upload_images_widget();
             $this->arrImageIds = $objUploaderNggAdmin->arrImageIds;
             $this->strGalleryPath = $objUploaderNggAdmin->strGalleryPath;
             $this->arrImageNames = $objUploaderNggAdmin->arrImageNames;
             if (is_array($objUploaderNggAdmin->arrThumbReturn) && count($objUploaderNggAdmin->arrThumbReturn) > 0) {
                 foreach ($objUploaderNggAdmin->arrThumbReturn as $strReturnMsg) {
                     if ($strReturnMsg != '1') {
                         $this->arrErrorMsg_widg[] = $strReturnMsg;
                     }
                 }
                 $this->arrImageMsg_widg[] = get_option('npu_upload_success') ? get_option('npu_upload_success') : __('Thank you! Your image has been submitted and is pending review.', 'nextgen-public-uploader');
                 $this->sendEmail();
             }
             //Used in update_details method.
             if (is_array($this->arrImageIds) && count($this->arrImageIds) > 0) {
                 foreach ($this->arrImageIds as $imageId) {
                     $pic = nggdb::find_image($imageId);
                     $objEXIF = new nggMeta($pic->imagePath);
                     $this->strTitle = $objEXIF->get_META('title');
                     $this->strDescription = $objEXIF->get_META('caption');
                     $this->strKeywords = $objEXIF->get_META('keywords');
                     $this->strTimeStamp = $objEXIF->get_date_time();
                 }
             } else {
                 $this->arrErrorMsg_widg[] = get_option('npu_no_file') ? get_option('npu_no_file') : __('You must select a file to upload', 'nextgen-public-uploader');
             }
             $this->update_details();
         } else {
             $this->arrErrorMsg_widg[] = get_option('npu_upload_failed') ? get_option('npu_upload_failed') : __('Upload failed!', 'nextgen-public-uploader');
         }
         //If we've encountered any errors, delete?
         if (count($this->arrErrorMsg_widg) > 0 && (is_array($this->arrImageIds) && count($this->arrImageIds) > 0)) {
             $gal_id = !empty($_POST['galleryselect']) ? absint($_POST['galleryselect']) : 1;
             foreach ($this->arrImageIds as $intImageId) {
                 $filename = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$intImageId}' ");
                 if ($filename) {
                     $gallerypath = $wpdb->get_var($wpdb->prepare("SELECT path FROM {$wpdb->nggallery} WHERE gid = %d", $gal_id));
                     if ($gallerypath) {
                         @unlink(WINABSPATH . $gallerypath . '/thumbs/thumbs_' . $filename);
                         @unlink(WINABSPATH . $gallerypath . '/' . $filename);
                     }
                     $delete_pic = $wpdb->delete($wpdb->nggpictures, array('pid' => $intImageId), array('%d'));
                 }
             }
         }
     }
 }
/**
 * nggCreateImageBrowser()
 *
 * @access internal
 * @param array $picturelist
 * @param string $template (optional) name for a template file, look for imagebrowser-$template
 * @return the content
 */
function nggCreateImageBrowser($picturelist, $template = '')
{
    global $nggRewrite, $ngg;
    require_once dirname(__FILE__) . '/lib/meta.php';
    // $_GET from wp_query
    $pid = get_query_var('pid');
    // we need to know the current page id
    $current_page = get_the_ID() == false ? 0 : get_the_ID();
    // create a array with id's for better walk inside
    foreach ($picturelist as $picture) {
        $picarray[] = $picture->pid;
    }
    $total = count($picarray);
    if (!empty($pid)) {
        if (is_numeric($pid)) {
            $act_pid = intval($pid);
        } else {
            // in the case it's a slug we need to search for the pid
            foreach ($picturelist as $key => $picture) {
                if ($picture->image_slug == $pid) {
                    $act_pid = $key;
                    break;
                }
            }
        }
    } else {
        reset($picarray);
        $act_pid = current($picarray);
    }
    // get ids for back/next
    $key = array_search($act_pid, $picarray);
    if (!$key) {
        $act_pid = reset($picarray);
        $key = key($picarray);
    }
    $back_pid = $key >= 1 ? $picarray[$key - 1] : end($picarray);
    $next_pid = $key < $total - 1 ? $picarray[$key + 1] : reset($picarray);
    // get the picture data
    $picture = nggdb::find_image($act_pid);
    // if we didn't get some data, exit now
    if ($picture == null) {
        return;
    }
    // add more variables for render output
    $picture->href_link = $picture->get_href_link();
    $args['pid'] = $ngg->options['usePermalinks'] ? $picturelist[$back_pid]->image_slug : $back_pid;
    $picture->previous_image_link = $nggRewrite->get_permalink($args);
    $picture->previous_pid = $back_pid;
    $args['pid'] = $ngg->options['usePermalinks'] ? $picturelist[$next_pid]->image_slug : $next_pid;
    $picture->next_image_link = $nggRewrite->get_permalink($args);
    $picture->next_pid = $next_pid;
    $picture->number = $key + 1;
    $picture->total = $total;
    $picture->linktitle = empty($picture->description) ? ' ' : htmlspecialchars(stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')));
    $picture->alttext = empty($picture->alttext) ? ' ' : html_entity_decode(stripslashes(nggGallery::i18n($picture->alttext, 'pic_' . $picture->pid . '_alttext')));
    $picture->description = empty($picture->description) ? ' ' : html_entity_decode(stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')));
    $picture->anchor = 'ngg-imagebrowser-' . $picture->galleryid . '-' . $current_page;
    // filter to add custom content for the output
    $picture = apply_filters('ngg_image_object', $picture, $act_pid);
    // let's get the meta data
    $meta = new nggMeta($act_pid);
    $meta->sanitize();
    $exif = $meta->get_EXIF();
    $iptc = $meta->get_IPTC();
    $xmp = $meta->get_XMP();
    $db = $meta->get_saved_meta();
    //if we get no exif information we try the database
    $exif = $exif == false ? $db : $exif;
    // look for imagebrowser-$template.php or pure imagebrowser.php
    $filename = empty($template) ? 'imagebrowser' : 'imagebrowser-' . $template;
    // create the output
    $out = nggGallery::capture($filename, array('image' => $picture, 'meta' => $meta, 'exif' => $exif, 'iptc' => $iptc, 'xmp' => $xmp, 'db' => $db));
    return $out;
}
 public function handleUpload_widget()
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/class.npu_uploader.php';
     require_once NGGALLERY_ABSPATH . '/lib/meta.php';
     $ngg->options['swfupload'] = false;
     if ($_POST['uploadimage_widget']) {
         check_admin_referer('ngg_addgallery');
         if ($_FILES['MF__F_0_0']['error'] == 0) {
             $objUploaderNggAdmin = new UploaderNggAdmin();
             $messagetext = $objUploaderNggAdmin->upload_images_widget();
             $this->arrImageIds = $objUploaderNggAdmin->arrImageIds;
             $this->strGalleryPath = $objUploaderNggAdmin->strGalleryPath;
             $this->arrImageNames = $objUploaderNggAdmin->arrImageNames;
             if (is_array($objUploaderNggAdmin->arrThumbReturn) && count($objUploaderNggAdmin->arrThumbReturn) > 0) {
                 foreach ($objUploaderNggAdmin->arrThumbReturn as $strReturnMsg) {
                     if ($strReturnMsg != '1') {
                         $this->arrErrorMsg_widg[] = $strReturnMsg;
                     }
                 }
                 if (get_option('npu_upload_success')) {
                     $this->arrImageMsg_widg[] = get_option('npu_upload_success');
                 } else {
                     $this->arrImageMsg_widg[] = "Thank you! Your image has been submitted and is pending review.";
                 }
                 $this->sendEmail();
             }
             if (is_array($this->arrImageIds) && count($this->arrImageIds) > 0) {
                 foreach ($this->arrImageIds as $imageId) {
                     $pic = nggdb::find_image($imageId);
                     $objEXIF = new nggMeta($pic->imagePath);
                     $this->strTitle = $objEXIF->get_META('title');
                     $this->strDescription = $objEXIF->get_META('caption');
                     $this->strKeywords = $objEXIF->get_META('keywords');
                     $this->strTimeStamp = $objEXIF->get_date_time();
                 }
             } else {
                 if (get_option('npu_no_file')) {
                     $this->arrErrorMsg_widg[] = get_option('npu_no_file');
                 } else {
                     $this->arrErrorMsg_widg[] = "You must select a file to upload";
                 }
             }
             $this->update_details();
         } else {
             if (get_option('npu_upload_failed')) {
                 $this->arrErrorMsg_widg[] = get_option('npu_upload_failed');
             } else {
                 $this->arrErrorMsg_widg[] = "Upload failed!";
             }
         }
         if (count($this->arrErrorMsg_widg) > 0 && (is_array($this->arrImageIds) && count($this->arrImageIds) > 0)) {
             $gal_id = $_POST['galleryselect'];
             foreach ($this->arrImageIds as $intImageId) {
                 $filename = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$intImageId}' ");
                 if ($filename) {
                     $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$gal_id}' ");
                     if ($gallerypath) {
                         @unlink(WINABSPATH . $gallerypath . '/thumbs/thumbs_' . $filename);
                         @unlink(WINABSPATH . $gallerypath . '/' . $filename);
                     }
                     $delete_pic = $wpdb->query("DELETE FROM {$wpdb->nggpictures} WHERE pid = {$intImageId}");
                 }
             }
         }
     }
 }
Exemple #10
0
/**
 * nggSinglePicture() - show a single picture based on the id
 * 
 * @access public 
 * @param int $imageID, db-ID of the image
 * @param int (optional) $width, width of the image
 * @param int (optional) $height, height of the image
 * @param string $mode (optional) could be none, watermark, web20
 * @param string $float (optional) could be none, left, right
 * @param string $template (optional) name for a template file, look for singlepic-$template
 * @param string $caption (optional) additional caption text
 * @return the content
 */
function nggSinglePicture($imageID, $width = 250, $height = 250, $mode = '', $float = '', $template = '', $caption = '')
{
    global $post;
    $ngg_options = nggGallery::get_option('ngg_options');
    // get picturedata
    $picture = nggdb::find_image($imageID);
    // if we didn't get some data, exit now
    if ($picture == null) {
        return __('[SinglePic not found]', 'nggallery');
    }
    // add float to img
    if (!empty($float)) {
        switch ($float) {
            case 'left':
                $float = ' ngg-left';
                break;
            case 'right':
                $float = ' ngg-right';
                break;
            case 'center':
                $float = ' ngg-center';
                break;
            default:
                $float = '';
                break;
        }
    }
    // check fo cached picture
    if ($ngg_options['imgCacheSinglePic'] && $post->post_status == 'publish') {
        $picture->thumbnailURL = $picture->cached_singlepic_file($width, $height, $mode);
    } else {
        $picture->thumbnailURL = NGGALLERY_URLPATH . 'nggshow.php?pid=' . $imageID . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;mode=' . $mode;
    }
    // add more variables for render output
    $picture->href_link = $picture->get_href_link();
    $picture->alttext = html_entity_decode(stripslashes($picture->alttext));
    $picture->description = html_entity_decode(stripslashes($picture->description));
    $picture->classname = 'ngg-singlepic' . $float;
    $picture->thumbcode = $picture->get_thumbcode('singlepic' . $imageID);
    $picture->height = (int) $height;
    $picture->width = (int) $width;
    $picture->caption = $caption;
    // let's get the meta data
    $meta = new nggMeta($picture->imagePath);
    $exif = $meta->get_EXIF();
    $iptc = $meta->get_IPTC();
    $xmp = $meta->get_XMP();
    // look for singlepic-$template.php or pure singlepic.php
    $filename = empty($template) ? 'singlepic' : 'singlepic-' . $template;
    // create the output
    $out = nggGallery::capture($filename, array('image' => $picture, 'meta' => $meta, 'exif' => $exif, 'iptc' => $iptc, 'xmp' => $xmp));
    $out = apply_filters('ngg_show_singlepic_content', $out, $picture);
    return $out;
}
Exemple #11
0
 function get_MetaData($picPath)
 {
     // must be Gallery absPath + filename
     require_once NGGALLERY_ABSPATH . '/lib/meta.php';
     $meta = array();
     $pdata = new nggMeta($picPath);
     $meta['title'] = $pdata->get_META('title');
     $meta['caption'] = $pdata->get_META('caption');
     $meta['keywords'] = $pdata->get_META('keywords');
     $meta['timestamp'] = $pdata->get_date_time();
     return $meta;
 }
Exemple #12
0
 /**
  * nggAdmin::get_MetaData()
  * 
  * @class nggAdmin
  * @require NextGEN Meta class
  * @param int $id image ID
  * @return array metadata
  */
 function get_MetaData($id)
 {
     require_once NGGALLERY_ABSPATH . '/lib/meta.php';
     $meta = array();
     $pdata = new nggMeta($id);
     $meta['title'] = trim($pdata->get_META('title'));
     $meta['caption'] = trim($pdata->get_META('caption'));
     $meta['keywords'] = trim($pdata->get_META('keywords'));
     $meta['timestamp'] = $pdata->get_date_time();
     // this contain other useful meta information
     $meta['common'] = $pdata->get_common_meta();
     return $meta;
 }