本文整理汇总了PHP中get_resized_image_from_uploaded_file函数的典型用法代码示例。如果您正苦于以下问题:PHP get_resized_image_from_uploaded_file函数的具体用法?PHP get_resized_image_from_uploaded_file怎么用?PHP get_resized_image_from_uploaded_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_resized_image_from_uploaded_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_site_domain
// Default site attributes
$site->name = $name;
$site->description = $description;
$site->email = "noreply@" . get_site_domain($site->getGUID());
$site->url = $url;
// site category
$site->category = $category;
// Site icon
if (get_resized_image_from_uploaded_file("icon", 16, 16)) {
// prepare image sizes
$topbar = get_resized_image_from_uploaded_file("icon", 16, 16, true);
$tiny = get_resized_image_from_uploaded_file("icon", 25, 25, true);
$small = get_resized_image_from_uploaded_file("icon", 40, 40, true);
$medium = get_resized_image_from_uploaded_file("icon", 100, 100, true);
$large = get_resized_image_from_uploaded_file("icon", 200, 200);
$master = get_resized_image_from_uploaded_file("icon", 500, 500);
// Add images to Subsite
$site->uploadIcon("topbar", $topbar);
$site->uploadIcon("favicon", $topbar);
$site->uploadIcon("tiny", $tiny);
$site->uploadIcon("small", $small);
$site->uploadIcon("medium", $medium);
$site->uploadIcon("large", $large);
$site->uploadIcon("master", $master);
}
$site->setMembership($membership);
// allow the site to be hidden
$site->setVisibility($visibility);
if ($membership == Subsite::MEMBERSHIP_INVITATION) {
// disable registration on invitation only sites
set_config("allow_registration", false, $site->getGUID());
示例2: blog_tools_remove_blog_icon
}
}
// only try to save base entity if no errors
if (!$error) {
if ($blog->save()) {
// handle icon upload
if (get_input("remove_icon") == "yes") {
// remove existing icons
blog_tools_remove_blog_icon($blog);
} elseif (($icon_file = get_resized_image_from_uploaded_file("icon", 100, 100)) && ($icon_sizes = elgg_get_config("icon_sizes"))) {
// create icon
$prefix = "blogs/" . $blog->getGUID();
$fh = new ElggFile();
$fh->owner_guid = $blog->getOwnerGUID();
foreach ($icon_sizes as $icon_name => $icon_info) {
if ($icon_file = get_resized_image_from_uploaded_file("icon", $icon_info["w"], $icon_info["h"], $icon_info["square"], $icon_info["upscale"])) {
$fh->setFilename($prefix . $icon_name . ".jpg");
if ($fh->open("write")) {
$fh->write($icon_file);
$fh->close();
}
}
}
$blog->icontime = time();
}
// remove sticky form entries
elgg_clear_sticky_form('blog');
// remove autosave draft if exists
$blog->deleteAnnotations('blog_auto_save');
// no longer a brand new post.
$blog->deleteMetadata('new_post');
示例3: elgg_get_plugin_from_id
<?php
$plugin = elgg_get_plugin_from_id("theme_eersel");
$fh = new ElggFile();
$fh->owner_guid = $plugin->getGUID();
$prefix = "slider_images/";
for ($i = 1; $i <= 5; $i++) {
$tmp = get_resized_image_from_uploaded_file("slider_image_" . $i, 100, 100);
if (!empty($tmp)) {
$icon = get_uploaded_file("slider_image_" . $i);
$fh->setFilename($prefix . $i . ".jpg");
$fh->open("write");
$fh->write($icon);
$fh->close();
}
}
system_message(elgg_echo("theme_eersel:action:slider_upload:done"));
forward(REFERER);
示例4: profile_manager_action_register_hook
/**
* Function to check if custom fields on register have been filled (if required)
* Also generates a username if needed
*
* @param string $hook_name name of the hook
* @param string $entity_type type of the hook
* @param unknown $return_value return value
* @param unknown $parameters hook parameters
*
* @return void
*/
function profile_manager_action_register_hook($hook_name, $entity_type, $return_value, $parameters)
{
elgg_make_sticky_form('register');
elgg_make_sticky_form('profile_manager_register');
// validate mandatory profile fields
$profile_icon = elgg_get_plugin_setting("profile_icon_on_register", "profile_manager");
// general terms
$terms = elgg_get_plugin_setting("registration_terms", "profile_manager");
// new
$profile_type_guid = get_input("custom_profile_fields_custom_profile_type", false);
$fields = profile_manager_get_categorized_fields(null, true, true, true, $profile_type_guid);
$required_fields = array();
if (!empty($fields["categories"])) {
foreach ($fields["categories"] as $cat_guid => $cat) {
$cat_fields = $fields["fields"][$cat_guid];
foreach ($cat_fields as $field) {
if ($field->show_on_register == "yes" && $field->mandatory == "yes") {
$required_fields[] = $field;
}
}
}
}
if ($terms || $required_fields || $profile_icon == "yes") {
$custom_profile_fields = array();
foreach ($_POST as $key => $value) {
if (strpos($key, "custom_profile_fields_") == 0) {
$key = substr($key, 22);
$custom_profile_fields[$key] = $value;
}
}
foreach ($required_fields as $entity) {
$passed_value = trim($custom_profile_fields[$entity->metadata_name]);
if (strlen($passed_value) < 1) {
register_error(elgg_echo("profile_manager:register_pre_check:missing", array($entity->getTitle())));
forward(REFERER);
}
}
if ($profile_icon == "yes") {
$profile_icon = $_FILES["profile_icon"];
$error = false;
if (empty($profile_icon["name"])) {
register_error(elgg_echo("profile_manager:register_pre_check:missing", array("profile_icon")));
$error = true;
} elseif ($profile_icon["error"] != 0) {
register_error(elgg_echo("profile_manager:register_pre_check:profile_icon:error"));
$error = true;
} else {
// test if we can handle the image
$image = get_resized_image_from_uploaded_file('profile_icon', '10', '10', true, false);
if (!$image) {
register_error(elgg_echo("profile_manager:register_pre_check:profile_icon:nosupportedimage"));
$error = true;
}
}
if ($error) {
forward(REFERER);
}
}
if ($terms) {
$terms_accepted = get_input("accept_terms");
if ($terms_accepted !== "yes") {
register_error(elgg_echo("profile_manager:register_pre_check:terms"));
forward(REFERER);
}
}
}
// generate username
$username = get_input('username');
$email = get_input('email');
if (empty($username) && !empty($email) && elgg_get_plugin_setting("generate_username_from_email", "profile_manager") == "yes") {
$email_parts = explode('@', $email);
$base_username = $email_parts[0];
$tmp_username = $base_username;
$i = 1;
while (get_user_by_username($tmp_username)) {
$tmp_username = $base_username . $i;
$i++;
}
set_input('username', $tmp_username);
}
}
示例5: pathinfo
// custom image?
// right file type and not to big?
if ($image == 'customtimeline') {
if (substr_count($_FILES['timelinefile']['type'], 'image/') && isset($_FILES['timelinefile']) && $_FILES['timelinefile']['error'] == 0) {
$filename = "customtimeline";
$extension = pathinfo($_FILES['timelinefile']['name']);
$extension = $extension['extension'];
$filehandler = new ElggFile();
$filehandler->setFilename($filename);
$filehandler->open("write");
$filehandler->write(get_uploaded_file('timelinefile'));
$filehandler->close();
$thumbnail = new ElggFile();
$thumbnail->setFilename($filename . "_thumb");
$thumbnail->open("write");
$thumbnail->write(get_resized_image_from_uploaded_file('timelinefile', 150, 150, false));
$thumbnail->close();
$timelineURL = 'pg/timeline_theme/getbackground?id=' . $current_user;
} else {
register_error(elgg_echo('timelinestyle:timeline:error:image'));
forward($_SERVER['HTTP_REFERER']);
}
} else {
$timelineURL = $image;
}
if (create_metadata($timelinestyle_object->guid, 'timeline-image', $timelineURL, 'string', $_SESSION['guid'], $access_id) == false || empty($timelineURL)) {
$error = true;
}
}
// repeat
if (get_input('timeline-repeat')) {
示例6: foreach
$event->endregistration_day = $endregistration_day;
$event->event_interested = 1;
$metadata_fields = ['shortdescription', 'comments_on', 'registration_ended', 'registration_needed', 'show_attendees', 'notify_onsignup', 'waiting_list', 'venue', 'contact_details', 'website', 'organizer', 'fee', 'fee_details', 'register_nologin', 'waiting_list_enabled', 'registration_completed', 'organizer_guids', 'contact_guids'];
foreach ($metadata_fields as $field) {
$event->{$field} = get_input($field);
}
$has_days = $event->hasEventDays();
$event->generateInitialProgramData();
$icon_sizes = elgg_get_icon_sizes('object', 'event');
$icon_file = get_resized_image_from_uploaded_file('icon', 100, 100);
if ($icon_file) {
// create icons
$fh = new \ElggFile();
$fh->owner_guid = $event->guid;
foreach ($icon_sizes as $icon_name => $icon_info) {
$icon_file = get_resized_image_from_uploaded_file('icon', $icon_info['w'], $icon_info['h'], $icon_info['square'], $icon_info['upscale']);
if ($icon_file) {
$fh->setFilename("{$icon_name}.jpg");
if ($fh->open('write')) {
$fh->write($icon_file);
$fh->close();
}
}
}
$event->icontime = time();
} elseif (get_input('delete_current_icon')) {
$event->deleteIcon();
}
$ia = elgg_set_ignore_access(true);
$order = 0;
$questions = get_input('questions');
示例7: gatekeeper
gatekeeper();
$user_guid = elgg_get_logged_in_user_guid();
$site_guid = elgg_get_site_entity()->getGUID();
$path = ckeditor_extended_get_upload_path($user_guid);
if (!file_exists($path)) {
if (!@mkdir($path, 0700, true)) {
exit;
}
}
$upload = elgg_extract("upload", $_FILES);
if (empty($upload)) {
echo elgg_echo("ckeditor_extended:upload:no_upload");
return;
}
if (!get_resized_image_from_uploaded_file("upload", 200, 200)) {
echo elgg_echo("ckeditor_extended:upload:no_image");
return;
}
$filename = $upload["name"];
// check for uniqueness
if (elgg_get_plugin_setting('overwrite_uploaded_images', 'ckeditor_extended') === 'no') {
$filename_parts = explode('.', $filename);
$ext = array_pop($filename_parts);
$count = 0;
while (file_exists($path . $filename)) {
$count++;
$filename = implode('.', $filename_parts);
$filename .= "_{$count}";
$filename .= ".{$ext}";
}
示例8: gatekeeper
* @link http://elgg.com/
*/
gatekeeper();
action_gatekeeper();
$user = page_owner_entity();
if (!$user) {
$user = $_SESSION['user'];
}
// If we were given a correct icon
if (isloggedin() && $user && $user->canEdit()) {
$topbar = get_resized_image_from_uploaded_file('profileicon', 16, 16, true);
$tiny = get_resized_image_from_uploaded_file('profileicon', 25, 25, true);
$small = get_resized_image_from_uploaded_file('profileicon', 40, 40, true);
$medium = get_resized_image_from_uploaded_file('profileicon', 100, 100, true);
$large = get_resized_image_from_uploaded_file('profileicon', 200, 200);
$master = get_resized_image_from_uploaded_file('profileicon', 550, 550);
if ($small !== false && $medium !== false && $large !== false && $tiny !== false) {
$filehandler = new ElggFile();
$filehandler->owner_guid = $user->getGUID();
$filehandler->setFilename("profile/" . $user->username . "large.jpg");
$filehandler->open("write");
$filehandler->write($large);
$filehandler->close();
$filehandler->setFilename("profile/" . $user->username . "medium.jpg");
$filehandler->open("write");
$filehandler->write($medium);
$filehandler->close();
$filehandler->setFilename("profile/" . $user->username . "small.jpg");
$filehandler->open("write");
$filehandler->write($small);
$filehandler->close();
示例9: time
$fh->write($contents);
$fh->close();
$news->topPhotoTime = time();
$news->save();
}
if ($guid && $featured_photo == "remove") {
$fh = new ElggFile();
$fh->owner_guid = $news->guid;
$fh->setFilename("featured_photo.jpg");
$fh->delete();
$news->featuredPhotoTime = null;
$news->save();
} elseif (get_resized_image_from_uploaded_file("featured_photo", 1298, 730)) {
$fh = new ElggFile();
$fh->owner_guid = $news->guid;
$fh->setFilename("featured_photo.jpg");
$fh->open("write");
$contents = get_resized_image_from_uploaded_file("featured_photo", 1298, 730);
$fh->write($contents);
$fh->close();
$news->featuredPhotoTime = time();
$news->save();
}
elgg_clear_sticky_form('news');
if ($guid) {
system_message(elgg_echo('news:edited'));
forward($news->getURL());
} else {
system_message(elgg_echo('news:added'));
forward('/news');
}
示例10: elgg_get_site_entity
<?php
$site = elgg_get_site_entity();
if (!elgg_is_admin_logged_in()) {
register_error(elgg_echo("noaccess"));
forward("");
}
$banner = array("show" => get_input("show"), "title" => get_input("title"), "description" => get_input("description"), "url" => get_input("url"));
$contents = get_resized_image_from_uploaded_file("photo", 1280, 330);
if ($contents) {
$banner['photoTime'] = time();
$fh = new ElggFile();
$fh->owner_guid = $site->guid;
$fh->setFilename("banner_photo.jpg");
$fh->open("write");
$fh->write($contents);
$fh->close();
}
elgg_set_plugin_setting("banner", serialize($banner), "rijkshuisstijl");
forward("");
示例11: profiles_go_add_profile_icon
/**
* Function to upload a profile icon on register of a user
*
* @param ElggUser $user The user to add the profile icons to
*
* @return boolean
*/
function profiles_go_add_profile_icon($user)
{
$icon_sizes = elgg_get_config('icon_sizes');
// get the images and save their file handlers into an array
// so we can do clean up if one fails.
$files = array();
foreach ($icon_sizes as $name => $size_info) {
$resized = get_resized_image_from_uploaded_file('profile_icon', $size_info['w'], $size_info['h'], $size_info['square'], $size_info['upscale']);
if ($resized) {
$file = new ElggFile();
$file->owner_guid = $user->guid;
$file->setFilename("profile/{$user->guid}{$name}.jpg");
$file->open('write');
$file->write($resized);
$file->close();
$files[] = $file;
} else {
// cleanup on fail
foreach ($files as $file) {
$file->delete();
}
register_error(elgg_echo('avatar:resize:fail'));
return false;
}
}
$user->icontime = time();
return true;
}
示例12: engap_faceupload_page_handler
function engap_faceupload_page_handler($page)
{
//elgg_load_library('elgg:facepp');
$ia = elgg_set_ignore_access(true);
header('Access-Control-Allow-Origin: *');
$image_title = $_POST['image_title'];
$image_pos = $_POST['image_pos'];
$user = get_user_by_username($_POST['username']);
login($user);
if ($image_pos == 0) {
$guid = $user->guid;
$icon_sizes = elgg_get_config('icon_sizes');
$tfiles = array();
foreach ($icon_sizes as $name => $size_info) {
$resized = get_resized_image_from_uploaded_file('file', $size_info['w'], $size_info['h'], $size_info['square'], $size_info['upscale']);
if ($resized) {
//@todo Make these actual entities. See exts #348.
$file = new ElggFile();
$file->owner_guid = $guid;
$file->setFilename("profile/{$guid}{$name}.jpg");
$file->open('write');
$file->write($resized);
$file->close();
$tmpfiles[] = $file;
} else {
// cleanup on fail
foreach ($tmpfiles as $tfile) {
$tfile->delete();
}
}
}
$user->icontime = time();
if (elgg_trigger_event('profileiconupdate', $user->type, $user)) {
error_log(elgg_echo("avatar:upload:success"));
$view = 'river/user/default/profileiconupdate';
elgg_delete_river(array('subject_guid' => $user->guid, 'view' => $view));
elgg_create_river_item(array('view' => $view, 'action_type' => 'update', 'subject_guid' => $user->guid, 'object_guid' => $user->guid));
}
}
elgg_set_ignore_access($ia);
echo $user->getIconURL('large');
return true;
}
示例13: actionRegister
/**
* Function to check if custom fields on register have been filled (if required)
* Also generates a username if needed
*
* @param string $hook_name name of the hook
* @param string $entity_type type of the hook
* @param unknown $return_value return value
* @param unknown $parameters hook parameters
*
* @return void
*/
public static function actionRegister($hook_name, $entity_type, $return_value, $parameters)
{
elgg_make_sticky_form('register');
elgg_make_sticky_form('profile_manager_register');
// validate mandatory profile fields
$profile_icon = elgg_get_plugin_setting('profile_icon_on_register', 'profile_manager');
// general terms
$terms = elgg_get_plugin_setting('registration_terms', 'profile_manager');
// new
$profile_type_guid = get_input('custom_profile_fields_custom_profile_type', false);
$fields = profile_manager_get_categorized_fields(null, true, true, true, $profile_type_guid);
$required_fields = [];
if (!empty($fields['categories'])) {
foreach ($fields['categories'] as $cat_guid => $cat) {
$cat_fields = $fields['fields'][$cat_guid];
foreach ($cat_fields as $field) {
if ($field->show_on_register == 'yes' && $field->mandatory == 'yes') {
$required_fields[] = $field;
}
}
}
}
if ($terms || $required_fields || $profile_icon == 'yes') {
$custom_profile_fields = [];
foreach ($_POST as $key => $value) {
if (strpos($key, 'custom_profile_fields_') == 0) {
$key = substr($key, 22);
$custom_profile_fields[$key] = $value;
}
}
foreach ($required_fields as $entity) {
$passed_value = $custom_profile_fields[$entity->metadata_name];
if (is_array($passed_value)) {
if (!count($passed_value)) {
register_error(elgg_echo('profile_manager:register_pre_check:missing', [$entity->getTitle()]));
forward(REFERER);
}
} else {
$passed_value = trim($passed_value);
if (strlen($passed_value) < 1) {
register_error(elgg_echo('profile_manager:register_pre_check:missing', [$entity->getTitle()]));
forward(REFERER);
}
}
}
if ($profile_icon == 'yes') {
$profile_icon = $_FILES['profile_icon'];
$error = false;
if (empty($profile_icon['name'])) {
register_error(elgg_echo('profile_manager:register_pre_check:missing', ['profile_icon']));
$error = true;
} elseif ($profile_icon['error'] != 0) {
register_error(elgg_echo('profile_manager:register_pre_check:profile_icon:error'));
$error = true;
} else {
// test if we can handle the image
$image = get_resized_image_from_uploaded_file('profile_icon', '10', '10', true, false);
if (!$image) {
register_error(elgg_echo('profile_manager:register_pre_check:profile_icon:nosupportedimage'));
$error = true;
}
}
if ($error) {
forward(REFERER);
}
}
if ($terms) {
$terms_accepted = get_input('accept_terms');
if ($terms_accepted !== 'yes') {
register_error(elgg_echo('profile_manager:register_pre_check:terms'));
forward(REFERER);
}
}
}
// generate username
$username = get_input('username');
$email = get_input('email');
if (empty($username) && elgg_get_plugin_setting('generate_username_from_email', 'profile_manager') == 'yes') {
set_input('username', self::generateUsernameFromEmail($email));
}
}
示例14: gatekeeper
*/
gatekeeper();
$profile_username = get_input('username');
$profile_owner = get_user_by_username($profile_username);
if (!$profile_owner || !$profile_owner instanceof ElggUser || !$profile_owner->canEdit()) {
register_error(elgg_echo('profile:icon:fail'));
forward($_SERVER['HTTP_REFERER']);
}
$profile_owner_guid = $profile_owner->getGUID();
//@todo make this configurable?
$icon_sizes = array('topbar' => array('w' => 16, 'h' => 16, 'square' => TRUE), 'tiny' => array('w' => 25, 'h' => 25, 'square' => TRUE), 'small' => array('w' => 40, 'h' => 40, 'square' => TRUE), 'medium' => array('w' => 100, 'h' => 100, 'square' => TRUE), 'large' => array('w' => 200, 'h' => 200, 'square' => FALSE), 'master' => array('w' => 1600, 'h' => 1600, 'square' => FALSE));
// get the images and save their file handlers into an array
// so we can do clean up if one fails.
$files = array();
foreach ($icon_sizes as $name => $size_info) {
$resized = get_resized_image_from_uploaded_file('profileicon', $size_info['w'], $size_info['h'], $size_info['square']);
if ($resized) {
//@todo Make these actual entities. See exts #348.
$file = new ElggFile();
$file->owner_guid = $profile_owner_guid;
$file->setFilename("profile/{$profile_username}{$name}.jpg");
$file->open('write');
$file->write($resized);
$file->close();
$files[] = $file;
} else {
// cleanup on fail
foreach ($files as $file) {
$file->delete();
}
system_message(elgg_echo('profile:icon:notfound'));
示例15: elgg_clear_sticky_form
// Force all new group content to be available only to members
$group->setContentAccessMode(ElggGroup::CONTENT_ACCESS_MODE_MEMBERS_ONLY);
}
$group->access_id = $visibility;
}
$group->save();
// group saved so clear sticky form
elgg_clear_sticky_form('groups');
// group creator needs to be member of new group and river entry created
if ($is_new_group) {
// @todo this should not be necessary...
elgg_set_page_owner_guid($group->guid);
$group->join($user);
elgg_create_river_item(array('view' => 'river/group/create', 'action_type' => 'create', 'subject_guid' => $user->guid, 'object_guid' => $group->guid));
}
$has_uploaded_icon = get_resized_image_from_uploaded_file("icon", 100, 100);
if ($has_uploaded_icon) {
$icon_sizes = elgg_get_config('icon_sizes');
$prefix = "groups/" . $group->guid;
$filehandler = new ElggFile();
$filehandler->owner_guid = $group->owner_guid;
$filehandler->setFilename($prefix . ".jpg");
$filehandler->open("write");
$filehandler->write(get_uploaded_file('icon'));
$filehandler->close();
$filename = $filehandler->getFilenameOnFilestore();
$sizes = array('tiny', 'small', 'medium', 'large');
$thumbs = array();
foreach ($sizes as $size) {
$thumbs[$size] = get_resized_image_from_existing_file($filename, $icon_sizes[$size]['w'], $icon_sizes[$size]['h'], $icon_sizes[$size]['square']);
}