Skip to content

Commit b5ed542

Browse files
committed
Merge branch 'master' into 1.4
2 parents 21745b8 + 9dfec70 commit b5ed542

4 files changed

Lines changed: 59 additions & 46 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/Tests/*
22
!Tests/.gitkeep
33
.DS_Store
4+
.idea

Controller/UploadController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ public function uploadImageAction(Request $request
3535

3636
$webDir = $config['uploadConfig']['webDir'];
3737
$webDir = substr($webDir, -strlen('/')) === '/' ? $webDir : $webDir . '/';
38-
if($config['uploadConfig']['generateFilename']){
38+
if($config['uploadConfig']['generateFilename']) {
3939
$filename = sha1(uniqid(mt_rand(), true));
4040
}
41-
else
42-
{
41+
else {
4342
$filename = $request->files->get('image_upload_file')->getClientOriginalName();
4443
if(file_exists($uploadUrl.$thumbsDir.'/'.$filename))
4544
{

Handler/UploadHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ function get_config_bytes($val) {
343343
case 'm':
344344
$val = (int)$val*1024;
345345
case 'k':
346-
$val= (int)$val*1024;
346+
$val = (int)$val*1024;
347347
}
348348
return $this->fix_integer_overflow($val);
349349
}

README.md

Lines changed: 55 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
Use branch master for compatibility with Syfony 2
2-
------------
3-
Use branch 1.3 for compatibility with Symfony 3
4-
------------
5-
Use 0.X releases for compatibility with bootstrap 2.x.
6-
------------
7-
Compatibility with bootstrap 2.X is no more maintained
8-
------------
9-
101
ComurImageBundle
11-
============
2+
================
3+
4+
## Introduction
125

136
Image upload / crop bundle for Symfony2
147

@@ -21,32 +14,51 @@ It uses beautiful [Jquery File Upload](http://blueimp.github.io/jQuery-File-Uplo
2114

2215
**New Since Version 0.2.0 !! you can also create sortable & croppable gallery widgets** without any specific configuration. It only needs an array typed property in your entity (and a text column in your database). See below for examples, screenshots and how to use it.
2316

17+
18+
## Which version use
19+
20+
|v SF|v Bundle|
21+
|---|---|
22+
|2.x|1.x|
23+
|3.x|2.x|
24+
|4.x|2.x|
25+
26+
27+
Use 0.X releases for compatibility with bootstrap 2.x.
28+
------------
29+
30+
Compatibility with bootstrap 2.X is no more maintained
31+
------------
32+
33+
I won't maintain Symfony 2 anymore, I will only merge PR on 1.2 branch for compatibility with SF2. If you need something you can always create a PR and I will merge it.
34+
--------
35+
2436
Screen shots
2537
------------
2638

2739
Here are some screen shots since i didn't have time to put a demo yet:
2840

29-
###Simple Image widget###
41+
### Simple Image widget ###
3042

3143
![alt tag](http://canomur.com/comur-image/images/image_widget_ss1.png)
3244

33-
###Gallery widget###
45+
### Gallery widget ###
3446

3547
![alt tag](http://canomur.com/comur-image/images/gallery_widget_ss1.png)
3648

37-
###Upload image screen###
49+
### Upload image screen ###
3850

3951
![alt tag](http://canomur.com/comur-image/images/upload_image_ss1.png)
4052

41-
###Select image from library screen###
53+
### Select image from library screen ###
4254

4355
![alt tag](http://canomur.com/comur-image/images/select_image_ss1.png)
4456

45-
###Crop image screen###
57+
### Crop image screen ###
4658

4759
![alt tag](http://canomur.com/comur-image/images/crop_image_ss1.png)
4860

49-
###Change gallery image order screen###
61+
### Change gallery image order screen ###
5062

5163
![alt tag](http://canomur.com/comur-image/images/order_image_ss1.png)
5264

@@ -130,49 +142,49 @@ Configuration
130142
gallery_thumb_size: 150
131143
gallery_dir: 'gallery'
132144
133-
###cropped_image_dir###
145+
### cropped_image_dir ###
134146
135147
It's used to determine relative directory name to put cropped images (see above).
136148
137149
**Default value:** 'cropped'
138150
139-
###thumbs_dir###
151+
### thumbs_dir ###
140152
141153
It's used to determine relative directory name to put thumbnails (see above).
142154
143155
**Default value:** 'thumbnails'
144156
145-
###media_lib_thumb_size###
157+
### media_lib_thumb_size ###
146158
147159
It's used to determine thumbnails size in pixels (squares) used in media library.
148160
149161
**Default value:** 150
150162
151-
###upload_dir###
163+
### upload_dir ###
152164
153165
Dirname of your public directory. It's used to check thumb existence in thumb twig helper.
154166
155167
**Default value:** 'web'
156168
157-
###translation_domain###
169+
### translation_domain ###
158170
159171
Domain name for translations. For instance two languages are provided (en & fr). To override the domain name, change this parameter to whatever you want.
160172
161173
**Default value:** 'ComurImageBundle'
162174
163-
###gallery_thumb_size###
175+
### gallery_thumb_size ###
164176
165177
That's the image size in pixels that you want to show in gallery widget. Gallery widget will automaticaly create square thums having this size and show them in the gallery widget.
166178
167179
**Default value:** 150
168180
169-
###gallery_dir###
181+
### gallery_dir ###
170182
171183
That's the gallery directory name. The widget will store all gallery images in a specific directory inside the root directory that you will give when you will add the widget to your forms.
172184
173185
**For eg.** if you put 'uploads/images' as webDir when you add the widget, gallery images will be stored in 'uploads/images/*[gallery_dir]*'. This is added to make gallery use easier so you don't have to add new functions to your entities to get gallery dirs.
174186
175-
#Usage#
187+
# Usage #
176188
177189
178190
There are two widgets provided with this bundle. They both have exacly same config parameters.
@@ -319,15 +331,15 @@ That's all ! This will create a widget like on the following image when you will
319331
320332
Gallery images will be stored in uploadUrl / gallery_dir (default is gallery). Cropped images will be stored in uploadUrl / gallery_dir / cropped_dir (same as image widget) and thumbs in uploadUrl / gallery_dir / cropped_dir / thumb_dir with specified width. So if you pu
321333
322-
##uploadConfig##
334+
## uploadConfig ##
323335
324-
###uploadRoute (optional)###
336+
### uploadRoute (optional) ###
325337
326338
Route called to send uploaded file. It's recommended to not change this parameter except if you know exactly what you do.
327339
328340
**Default value:** comur_api_upload
329341
330-
###uploadUrl (required)###
342+
### uploadUrl (required) ###
331343
332344
Absolute url to directory where put uploaded image. I recommend you to create a function in your entity and call it like it's showen in the example:
333345
@@ -353,79 +365,79 @@ Absolute url to directory where put uploaded image. I recommend you to create a
353365
}
354366
355367
356-
###webDir (required)###
368+
### webDir (required) ###
357369
358370
Url used to show your image in templates, must be relative url. If you created related functions as explained in uploadUrl section, then you can user getWebPath() function for webDir parameter.
359371
360-
###fileExt (optional)###
372+
### fileExt (optional) ###
361373
362374
Permitted image extensions.
363375
364376
**Default value:** '*.jpg;*.gif;*.png;*.jpeg'
365377
366-
###libraryDir (optional)###
378+
### libraryDir (optional) ###
367379
368380
Directory to look into for images to show in image library.
369381
370382
**Default value:** uploadUrl
371383
372-
###libraryRoute (optional)###
384+
### libraryRoute (optional) ###
373385
374386
Route called to get images to show in library. I recommend you to not change this parameter if you don't know exactly what it does.
375387
376388
**Default value:** comur_api_image_library
377389
378-
###showLibrary (optional)###
390+
### showLibrary (optional) ###
379391
380392
Set this to false if you don't want the user see existing images in libraryDir.
381393
382394
**Default value:** true
383395
384-
###saveOriginal (optional)###
396+
### saveOriginal (optional) ###
385397
386398
Use this parameter if you want to save original file's path (for eg. to show big image in a lightbox). You have to put property name of your entity and the bundle will use it to save original file path in it.
387399
388400
**Attention:** This parameter is disabled for gallery for instance. It will be implemented soon.
389401
390402
**Default value:** false
391403
392-
###generateFilename (optional)###
404+
### generateFilename (optional) ###
393405
394406
This parameter is used to generate an uniq file name. Setted to false, it will keep the original filename.
395407
396408
**Default value:** true
397409
398-
##cropConfig##
410+
## cropConfig ##
399411
400-
###minWidth (optional)###
412+
### minWidth (optional) ###
401413
402414
Minimum with of desired image.
403415
404416
**Default value:** 1
405417
406-
###minHeight (optional)###
418+
### minHeight (optional) ###
407419
408420
Minimum height of desired image.
409421
410422
**Default value:** 1
411-
###aspectRatio (optional)###
423+
### aspectRatio (optional) ###
412424
413425
True to aspect ratio of crop screen.
414426
415427
**Default value:** true
416428
417-
###cropRoute (optional)###
429+
### cropRoute (optional) ###
418430
419431
Route to crop action. I recommend you to not change this parameter if you don't know exactly what it does.
420432
421433
**Default value:** comur_api_crop
422434
423435
424-
###forceResize (optional)###
436+
### forceResize (optional) ###
425437
426438
If true, system will resize image to fit minWidth and minHeight.
427439
428-
###thumbs (optional)###
440+
### thumbs (optional) ###
429441
430442
Array of thums to create automaticly. System will resize images to fit maxWidth and maxHeight. It will put them in "uploadDir/cropped_images_dir/thumbs_dir/widthxheight-originalfilename.extension" so you can use included Thumb Twig extension to get them, ex:
431443
@@ -437,10 +449,11 @@ Array of thums to create automaticly. System will resize images to fit maxWidth
437449
438450
**New in 0.2.2:** You can use 'useAsFieldImage' option to use this thumb as image field's preview (in your form you will see this thumb instead of original cropped image). Usefull when you have big cropped images.
439451
440-
#TODO LIST#
452+
# TODO LIST #
441453
442454
* Create tests
443455
* Add more comments in the code
444456
* Think about removed image deletion (for now images are not deleted, you have to care about it by yourself…)
445457
* Update existing images list dynamicly after an image upload
446458
459+

0 commit comments

Comments
 (0)