當前位置: 首頁>>代碼示例>>PHP>>正文


PHP nggAdmin::get_MetaData方法代碼示例

本文整理匯總了PHP中nggAdmin::get_MetaData方法的典型用法代碼示例。如果您正苦於以下問題:PHP nggAdmin::get_MetaData方法的具體用法?PHP nggAdmin::get_MetaData怎麽用?PHP nggAdmin::get_MetaData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在nggAdmin的用法示例。


在下文中一共展示了nggAdmin::get_MetaData方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: import_MetaData

 /**
  * Import some meta data into the database (if avialable)
  * 
  * @class nggAdmin
  * @param array|int $imagesIds
  * @return string result code
  */
 function import_MetaData($imagesIds)
 {
     global $wpdb;
     require_once NGGALLERY_ABSPATH . '/lib/image.php';
     if (!is_array($imagesIds)) {
         $imagesIds = array($imagesIds);
     }
     foreach ($imagesIds as $imageID) {
         $image = nggdb::find_image($imageID);
         if (!$image->error) {
             $meta = nggAdmin::get_MetaData($image->pid);
             // get the title
             $alttext = empty($meta['title']) ? $image->alttext : $meta['title'];
             // get the caption / description field
             $description = empty($meta['caption']) ? $image->description : $meta['caption'];
             // get the file date/time from exif
             $timestamp = $meta['timestamp'];
             // first update database
             $result = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggpictures} SET \r\n\t\t\t\t\t\talttext = %s, \r\n\t\t\t\t\t\tdescription = %s, \r\n\t\t\t\t\t\timagedate = %s\r\n\t\t\t\t\tWHERE pid = %d", $alttext, $description, $timestamp, $image->pid));
             if ($result === false) {
                 return ' <strong>' . $image->filename . ' ' . __('(Error : Couldn\'t not update data base)', 'nggallery') . '</strong>';
             }
             //this flag will inform us that the import is already one time performed
             $meta['common']['saved'] = true;
             $result = nggdb::update_image_meta($image->pid, $meta['common']);
             if ($result === false) {
                 return ' <strong>' . $image->filename . ' ' . __('(Error : Couldn\'t not update meta data)', 'nggallery') . '</strong>';
             }
             // add the tags if we found some
             if ($meta['keywords']) {
                 $taglist = explode(',', $meta['keywords']);
                 wp_set_object_terms($image->pid, $taglist, 'ngg_tag');
             }
         } else {
             return ' <strong>' . $image->filename . ' ' . __('(Error : Couldn\'t not find image)', 'nggallery') . '</strong>';
         }
         // error check
     }
     return '1';
 }
開發者ID:ahsaeldin,項目名稱:projects,代碼行數:47,代碼來源:functions.php

示例2: import_MetaData

 function import_MetaData($imagesIds)
 {
     // add images to database
     global $wpdb;
     require_once NGGALLERY_ABSPATH . '/lib/image.php';
     if (!is_array($imagesIds)) {
         $imagesIds = array($imagesIds);
     }
     foreach ($imagesIds as $pic_id) {
         $picture = nggdb::find_image($pic_id);
         if (!$picture->error) {
             $meta = nggAdmin::get_MetaData($picture->imagePath);
             // get the title
             if (!($alttext = $meta['title'])) {
                 $alttext = $picture->alttext;
             }
             // get the caption / description field
             if (!($description = $meta['caption'])) {
                 $description = $picture->description;
             }
             // get the file date/time from exif
             $timestamp = $meta['timestamp'];
             // update database
             $result = $wpdb->query("UPDATE {$wpdb->nggpictures} SET alttext = '{$alttext}', description = '{$description}', imagedate = '{$timestamp}'  WHERE pid = {$pic_id}");
             // add the tags
             if ($meta['keywords']) {
                 $taglist = explode(",", $meta['keywords']);
                 wp_set_object_terms($pic_id, $taglist, 'ngg_tag');
             }
             // add tags
         }
         // error check
     }
     // foreach
     return true;
 }
開發者ID:pravinhirmukhe,項目名稱:flow1,代碼行數:36,代碼來源:functions.php


注:本文中的nggAdmin::get_MetaData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。