本文整理汇总了PHP中nggdb::insert_image方法的典型用法代码示例。如果您正苦于以下问题:PHP nggdb::insert_image方法的具体用法?PHP nggdb::insert_image怎么用?PHP nggdb::insert_image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nggdb
的用法示例。
在下文中一共展示了nggdb::insert_image方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copy_images
/**
* Copy images to another gallery
*
* @class nggAdmin
* @param array|int $pic_ids ID's of the images
* @param int $dest_gid destination gallery
* @return void
*/
function copy_images($pic_ids, $dest_gid)
{
require_once NGGALLERY_ABSPATH . '/lib/meta.php';
$errors = $messages = '';
if (!is_array($pic_ids)) {
$pic_ids = array($pic_ids);
}
// Get destination gallery
$destination = nggdb::find_gallery($dest_gid);
if ($destination == null) {
nggGallery::show_error(__('The destination gallery does not exist', 'nggallery'));
return;
}
// Check for folder permission
if (!is_writeable(WINABSPATH . $destination->path)) {
$message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), WINABSPATH . $destination->path);
nggGallery::show_error($message);
return;
}
// Get pictures
$images = nggdb::find_images_in_list($pic_ids);
$destination_path = WINABSPATH . $destination->path;
foreach ($images as $image) {
// WPMU action
if (nggWPMU::check_quota()) {
return;
}
$i = 0;
$tmp_prefix = '';
$destination_file_name = $image->filename;
while (file_exists($destination_path . '/' . $destination_file_name)) {
$tmp_prefix = 'copy_' . $i++ . '_';
$destination_file_name = $tmp_prefix . $image->filename;
}
$destination_file_path = $destination_path . '/' . $destination_file_name;
$destination_thumb_file_path = $destination_path . '/' . $image->thumbFolder . $image->thumbPrefix . $destination_file_name;
// Copy files
if (!@copy($image->imagePath, $destination_file_path)) {
$errors .= sprintf(__('Failed to copy image %1$s to %2$s', 'nggallery'), $image->filename, $destination_file_path) . '<br />';
continue;
}
// Copy backup file, if possible
@copy($image->imagePath . '_backup', $destination_file_path . '_backup');
// Copy the thumbnail if possible
@copy($image->thumbPath, $destination_thumb_file_path);
// Create new database entry for the image
$new_pid = nggdb::insert_image($destination->gid, $destination_file_name, $image->alttext, $image->description, $image->exclude);
if (!isset($new_pid)) {
$errors .= sprintf(__('Failed to copy database row for picture %s', 'nggallery'), $image->pid) . '<br />';
continue;
}
// Copy tags
nggTags::copy_tags($image->pid, $new_pid);
// Copy meta information
$meta = new nggMeta($image->pid);
nggdb::update_image_meta($new_pid, $meta->image->meta_data);
if ($tmp_prefix != '') {
$messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s) » The file already existed in the destination gallery.', 'nggallery'), $image->pid, $image->filename, $new_pid, $destination_file_name) . '<br />';
} else {
$messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s)', 'nggallery'), $image->pid, $image->filename, $new_pid, $destination_file_name) . '<br />';
}
}
// Finish by showing errors or success
if ($errors == '') {
$link = '<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $destination->gid . '" >' . $destination->title . '</a>';
$messages .= '<hr />' . sprintf(__('Copied %1$s picture(s) to gallery: %2$s .', 'nggallery'), count($images), $link);
}
if ($messages != '') {
nggGallery::show_message($messages);
}
if ($errors != '') {
nggGallery::show_error($errors);
}
return;
}
示例2: array
$ext = array('jpeg', 'jpg', 'png', 'gif');
if (!in_array($filepart['extension'], $ext)) {
$display = 'block';
$errormsg = 'sorry,the file is no valid image file!';
} else {
$dest_file = WINABSPATH . $gallerypath . '/' . $filename;
// save temp file to gallery
if (!@move_uploaded_file($_FILES['image']['tmp_name'], $dest_file)) {
nggGallery::show_error(__('Error, the file could not moved to : ', 'nggallery') . $dest_file);
continue;
}
if (!foto_chmod($dest_file)) {
nggGallery::show_error(__('Error, the file permissions could not set', 'nggallery'));
continue;
}
$pid = nggdb::insert_image($gid, $filename, $title, $description, 1);
$tags = explode(",", $tags);
wp_set_object_terms($pid, $tags, 'ngg_tag');
$wpdb->query("UPDATE {$wpdb->nggpictures} SET imagedate = now() WHERE pid = {$pid}");
$display = 'block';
$errormsg = 'your upload is successful,it will be reviewed.you can continue';
}
}
}
}
//输出页头keywords
$keywords = $cfg['keywords'];
//输出页面description
$description = $cfg['description'];
//输出$title
$page_title = $cfg['sitename'];