I am using CKFinder PHP 3.5.3.
When I upload an image, it creates only one default 150x150 thumbnail currently.
I tried the following configuration of a thumbnail on the config.php, but it doesn't work:
$config['thumbnails'] = array(
'enabled' => true,
'sizes' => array(
array('width' => '150', 'height' => '150', 'quality' => 80),
array('width' => '300', 'height' => '300', 'quality' => 80),
array('width' => '500', 'height' => '500', 'quality' => 80),
),
'bmpSupported' => true,
);
I would like to create multiple thumbnails such as 150x150, 300x300 and 500x500 when upload an image.
How can I generate multiple thumbnails when I upload an image?
In CKFinder 3 thumbnails of different sizes are generated lazily, on demand. This means the thumbnail of a given size will not be generated until requested by CKFinder's frontend. It's possible to change this behavior with a plugin. Here you can find a plugin I have created that enforces CKFinder to generate all the private thumbnails immediately after the file is uploaded.
Related
I created a custom entity with an image field. But I can not display the alt and title fields.
Here is my code:
$fields['main_img'] = BaseFieldDefinition::create('image')
->setLabel(t('Main image of the hardware'))
->setSettings([
'file_directory' => 'hardware',
'file_extensions' => 'png jpg jpeg',
])
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'image',
'weight' => -30,
))
->setDisplayOptions('form', array(
'label' => 'above',
'type' => 'image_image',
'weight' => -30,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
Could you tell me how to display the alt and title fields of my image and maybe someone knows where the documentation is for doing that because I can not find it?
Thank you all
I loaded one of my node field definitions with $node->getFieldDefinitions():
I believe you can try something like this:
->setDisplayOptions('form', array(
'label' => 'above',
'type' => 'image_image',
'weight' => -30,
'settings' => [
'alt_field' => TRUE,
'alt_field_required' => TRUE, //optional
'title_field' => TRUE,
'title_field_required' => TRUE, //optional
],
))
Thank Dmytro.
I feel a little stupid but it's life.
It was enough to add 'alt_field_required' => FALSE and 'title_field' => TRUE in setSettings.
But as title and alt is displayed that when we download an image I thought it did not work.
A day of lost!
I am using CI version 3.1.2 to process an image and using Windows 8. My problem is every time i process an image and trying to create a thumbnail, i am countering a message "Unable to save the image. Please make sure the image and file directory are writable". This is occurred when trying to save the copy of thumbnail into different location. Here are my codes processing the image:
$this->original_path = realpath(APPPATH.'../assets/galery/full');
// Uploading image
$config = [
'allowed_types' => 'jpg|jpeg|gif|png',
'upload_path' => $this->original_path,
'max_size' => 2048,
'maintain_ratio' => true,
'file_name' => 'img_'.strtotime(date('d-m-y-H-i-s')), // miss type
'overwrite' => true,
'remove_spaces' => true
];
$this->load->library('upload', $config);
$this->upload->do_upload('galery');
$file_name = $this->upload->file_name;
// Processing image, success processing image
$this->load->library('image_lib');
$img = [
'image_library' => 'gd2',
'source_image' => $this->original_path.'/'.$file_name,
'maintain_ratio' => true,
'width' => 600
];
$this->image_lib->initialize($img);
$this->image_lib->resize();
// This is fail, with message "Unable to save the image... using(var_dump())
$thumb = [
'source_image' => $this->original_path.'/'.$file_name,
'new_image' => '/assets/galery/small',
'maintain_ratio' => true,
'width' => 200
];
$this->image_lib->initialize($thumb);
$this->image_lib->resize();
I've tried different config, like using realpath(APPPATH.'../assets/galery/small'), but still no luck. It is success, by the way, when create config using 'create_thumb'.
But my purpose is, saving that thumbnail in another folder. How can i achieve that?
UPDATE
This change seem to work well. I change realpath(APPPATH.'../assets/galery/full') to realpath(APPPATH.'../assets/galery') and make several change in:
...
'upload_path' => $this->original_path.'/full'
...
'source_image' => $this->original_path.'/full/'.$file_name
...
'new_image' => $this->original_path.'/small/thumb_'.$file_name
Until now i'm still trying to make my code simple and put it in MY_Model. Thanks for all comment(s). If some one may have better solution, it would be nice to share here.
Hi i have this validaton for the images that validates only jpg and png types and also i aadded a filesize that is only 5mb. I want that when i will not select an image it will bypass. So no validation for selecting images. What happend is when i did not select an image it will validates to select valid image. How will i able to do this that when im not selecting an image it will not validate. Heres my validation below
'images' => [
'extension' => [
'rule' => [
'extension',
['png', 'jpg']
],
'allowEmpty'=>['Empty'],
'message' => 'Select valid image'
],
'fileSize' =>[
'rule'=>
'fileSize',
['<=', '5mb'],
'message' => 'Image must be less than 5mb'
]
],
this is just a simple one. Any help is muchly appreciated.
I want to resize the uploaded image as the ratio of 400 x 350. I use below code for this.
$config = array(
'image_library' => 'gd2',
'source_image' => $img_data['full_path'],
'new_image' => $this->upload_path. '/thumbs',
'maintain_ration' => FALSE,
'width' => 350,
'height' => 400
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
Codeigniter give me the image as the ratio of 400 x 340.
see if this could help.
Here is the link to the class required to accomplish the task you looking for
http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/
I want to resize an image while displaying it on form (100 * 100) in CodeIgniter, by using this function:
echo img('imagepath');
This will do it..
$image_properties = array(
'src' => 'imagepath',
'alt' => 'Me, demonstrating how to eat 4 slices of pizza at one time',
'class' => 'post_images',
'width' => '100',
'height' => '100',
'title' => 'That was quite a night'
);
echo img($image_properties);
Source: Codeigniter