本文整理汇总了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;
}