/** * 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(); // hook for addon plugin to add more meta fields $meta = apply_filters('ngg_get_image_metadata', $meta, $pdata); return $meta; }
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&ewww_force=1&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&ewww_attachment_ID=%d\">%s</a>", $id, __('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')); } } } } }
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&ewww_manual_nonce=$ewww_manual_nonce&ewww_force=1&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&ewww_manual_nonce=$ewww_manual_nonce&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; 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}"); } } } } }
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; }
/** * 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; }