本文整理匯總了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';
}
示例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;
}