Giter Site home page Giter Site logo

deuxhuithuit / image_upload Goto Github PK

View Code? Open in Web Editor NEW
10.0 6.0 8.0 106 KB

Image upload field for Symphony CMS 2.x

Home Page: http://symphonyextensions.com/extensions/image_upload/

License: MIT License

PHP 100.00%
symphony-cms symphony-cms-extension symphony-cms-images symphony-cms-upload

image_upload's Introduction

Field: Image upload

Github repo: https://github.com/deuxhuithuit/image_upload

1 About

A specialized version of the classic Upload field for images:

  • it accepts only images: bmp, jpg, jpeg, png, gif and svg.
  • optional, set a minimum width and / or height. If 0 or empty, no minimum limit will exist.
  • optional, set a maximum width and / or height. If 0 or empty, no maximum resize limit will exist.
  • optional, it will create unique filenames.

NB: The resize takes places upon save, if needed, no matter new or edited entry.

NB 2: SVG support requires Symphony 2.6.3 or this commit.

2 Installation

  1. Upload the image_upload folder found in this archive to your Symphony extensions folder.
  2. Enable it by selecting Image upload under System -> Extensions, choose Enable from the with-selected menu, then click Apply.
  3. You can now add Image upload field to your sections.

image_upload's People

Contributors

beaubbe avatar chobohub avatar devnix avatar nathanhornby avatar nitriques avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

image_upload's Issues

Svg is jitted in entry table preview

in prepareTableValue, when the image comes from a multilingual image upload, it does not have a mimetype so it can't determine if the image is a svg

SVG validation rules bugs

To be able to have a SVG, I have to clear the regex of the validation rules. When I click on "image+svg", it doesn't do anything. So I have to leave it empty.

If I go back to the blueprint of the section, it automaticly adds to normal image validation rule to the empty validation rule in the fields. So when I save the blueprints, it saves the validation rules. Therefore, if I go save the entry, all the SVG images are not valid anymore.

Error while trying to save in section editor in Symphony 2.5beta2, Image Upload 1.5

Symphony Fatal Database Error: Unknown column 'resize' in 'field list'

An error occurred while attempting to execute the following query

INSERT INTO `sym_fields_image_upload` (`field_id`, `destination`, `validator`, `unique`, `min_width`, `min_height`, `max_width`, `max_height`, `resize`) VALUES ('2', '/workspace/bilder', '/\\.(?:gif|jpe?g|png)$/i', 'yes', '920', '450', '920', '450', 'no')

Anything else I can contribute?

Please tag version 1.3 and 1.4

Since 1.4 is breaking compatibility with Symphony 2.3.2, could you please tag those two versions please ?

1.4 is the HEAD and 1.3 is this commit 63d9046

Php 7 - Security Issue

Need to use preg_replace_callback to modify /e .
field/field.image_upload.php,
line 608.

Wrong size, Permission Error

Hi, I've set the Max and Min for same size, and uploading a wrong size to test and the error returned is:
Destination folder is not writable. Please check permissions on /workspace/uploads/destaques.

So uploading correct size (1600x470) pass ok.

It would be good if error message return something like the size problem like: The image size is wrong. Please send image with width between %1 max and %2 min, and height between %3 max and %4 min.

PHP 7.2 . Symphony Warning: Use of undefined constant IMAGE_UPLOAD_NAME - assumed 'IMAGE_UPLOAD_NAME' (this will throw an Error in a future version of PHP)

PHP 7.2

Deprecated: idn_to_utf8(): INTL_IDNA_VARIANT_2003 is deprecated in /Users/xxx/Sites/xxx/symphony/lib/boot/defines.php on line 218

Symphony Warning: Use of undefined constant IMAGE_UPLOAD_NAME - assumed 'IMAGE_UPLOAD_NAME' (this will throw an Error in a future version of PHP)
An error occurred in /Users/xxx/Sites/xxx/extensions/image_upload/extension.driver.php around line 5

Resize not working

I setted the maximum width and height to 680 and 3000 but if I upload a image bigger in width than 680px it doesn't resize it.
The image must exceed both max width and height to be resized ?

I'm using Symphony 2.2.5, latest version of this extension and I have JIT enabled. JIT works just fine, but this extension seems to not resize the images bigger than the maximum width setted

Call to undefined method Image::applyFilter()

It seems there is an issue using the latest integration branch of JIT, I guess it is due to the latests updates of JIT.

Call to undefined method Image::applyFilter()
/extensions/image_upload/fields/field.image_upload.php around line 60

Image ratio

In a case where the design needs a specific image ratio, the option to have a minimum height/width, a maximum height/width plus the ratio would be awesome.

It would give more flexibility for the images to have a range of size instead of blocking the min and max width/height so that the ratio is respected.

[Spelling] "Minimum"

In your field labels you spell "Minimum" with a "n" at the end :o) __('Minimun width (px)'),

Cannot update the extension

Updated my Symphony to 2.3.3 and trying to update this extension to 1.4 gives this error:

MySQL Error (1060): Duplicate column name 'resize' in query: ALTER TABLE `sym_fields_image_upload` ADD COLUMN `resize` enum('yes','no') NOT NULL DEFAULT 'yes'

image upload field show "OptionalOptional" text

image upload field, extension, version 1.5
Symphony, CMS, version 2.4

As showed in the following image the extension image upload field shows twice the word 'Optional' when you create a new entry.

field

thanks
Matteo

ALT and TITLE

Can we have title and alt on the field as well? Alt and Title are extremely important.

SVG preview glitches

When you save the entry with a big svg it has to unwanted effects:

  1. When it's too wide and in the aside section, the hole column goes under the main column. The image could be in the need of a "max-width: 100%"?
  2. It doesn't have a max-height eighter. So it takes a lot of place if the image is tall.

[Suggestion] lower Image Quality from 100 to 80

I believe it is generally considered bad practice to have an image quality setting of 100 since that would result in images with much larger filesize than necessary and no perceivable enhanced quality (over say, 90).

In field.image_upload.php:54 you set the quality hardcoded to 100 so my assumption is that you could optimize this by setting it to a lower value (such as 85) or maybe use Image::DEFAULT_QUALITY (80)?

Think of the bytes! ;)

Problem when open_basedir enforced

When the PHP configuration "open_basedir" is set, an error occurs everytime I try to modify an already existing entry with an already set value for the Image Field. The problem doesn't occur when creating a new entry with an image, only when modifying.

Symphony version: 2.2.5
Image Upload version: 1.1.6
Tested on Windows Apache Server and Linux Apache.
To reproduce: set the PHP config "open_basedir" to the root directory of your website (also add the tmp folder PHP is using for the file uploads), create a section containing an Image Upload field, create a new entry, then modify the same entry.

Note: the problem doesn't occur if I use the original File Upload field instead.

It seems that [field.image_upload.php:240] fieldUpload::getMetaInfo() is trying to get meta information about the "/" file (the path of the file is only "/").

Error output:

file_exists() [function.file-exists]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (C:\Windows\TEMP;C:\Users\Xavier\www\ta\centrecommercialrdl.ca)
An error occurred in C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\lib\toolkit\fields\field.upload.php around line 90
85: }
86:
87: public static function getMetaInfo($file, $type){
88: $meta = array();
89: var_dump($file);
90: if(!file_exists($file) || !is_readable($file)) return $meta;
91:
92: $meta['creation'] = DateTimeObj::get('c', filemtime($file));
93:
94: if(General::in_iarray($type, fieldUpload::$imageMimeTypes) && $array = @getimagesize($file)){

Backtrace:
[:0] GenericErrorHandler::handler();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\lib\toolkit\fields\field.upload.php:90] file_exists();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\extensions\image_upload\fields\field.image_upload.php:240] fieldUpload::getMetaInfo();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\lib\toolkit\class.entry.php:250] fieldImage_upload->checkPostFieldData();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\content\content.publish.php:859] Entry->checkPostData();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\content\content.publish.php:40] contentPublish->__actionEdit();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\content\content.publish.php:26] contentPublish->__switchboard();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\lib\toolkit\class.administrationpage.php:242] contentPublish->action();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\lib\core\class.administration.php:230] AdministrationPage->build();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\symphony\lib\core\class.administration.php:383] Administration->__buildPage();
[C:\Users\Xavier\www\ta\centrecommercialrdl.ca\public\index.php:25] Administration->display();

Database Query Log:
SET character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'; [0.0001]
SET CHARACTER SET 'utf8'; [0.0001]
SELECT SQL_CACHE session_data FROM sym_sessions WHERE session = 'b25191639705ce2c739bd7fcdbc92474' LIMIT 1; [0.0003]
SELECT SQL_CACHE name FROM sym_extensions WHERE status = 'enabled'; [0.0002]
SELECT SQL_CACHE id FROM sym_authors WHERE username = 'admin' AND password = 'xxx' LIMIT 1; [0.0003]
UPDATE sym_authors SET last_seen = '2012-03-08 17:43:51' WHERE id = '1'; [0.0002]
SELECT SQL_CACHE * FROM sym_authors WHERE id IN (1) ORDER BY id ASC; [0.0001]
SELECT SQL_CACHE * FROM sym_extensions; [0.0003]
SELECT SQL_CACHE * FROM sym_sections ORDER BY sortorder ASC; [0.0004]
SELECT SQL_CACHE t1.name, t2.page, t2.delegate, t2.callback FROM sym_extensions as t1 INNER JOIN sym_extensions_delegates as t2 ON t1.id = t2.extension_id WHERE t1.status = 'enabled'; [0.0003]
SELECT SQL_CACHE section_id FROM sym_entries WHERE id = '14' LIMIT 1; [0.0002]
SELECT SQL_CACHE s.* FROM sym_sections AS s WHERE s.id = '1'; [0.0002]
SELECT SQL_CACHE e.id, e.section_id, e.author_id, UNIX_TIMESTAMP(e.creation_date) AS creation_date FROM sym_entries AS e WHERE 1 AND e.id IN ('14') AND e.section_id = '1'; [0.0002]
SELECT SQL_CACHE id FROM sym_fields WHERE parent_section = 1; [0.0002]
SELECT SQL_CACHE * FROM sym_entries_data_1 WHERE entry_id IN (14) ORDER BY id ASC; [0.0002]
SELECT SQL_CACHE * FROM sym_entries_data_2 WHERE entry_id IN (14) ORDER BY id ASC; [0.0002]
SELECT SQL_CACHE * FROM sym_entries_data_3 WHERE entry_id IN (14) ORDER BY id ASC; [0.0002]
SELECT SQL_CACHE * FROM sym_entries_data_4 WHERE entry_id IN (14) ORDER BY id ASC; [0.0002]
SELECT SQL_CACHE * FROM sym_entries_data_7 WHERE entry_id IN (14) ORDER BY id ASC; [0.0001]
SELECT SQL_CACHE * FROM sym_entries_data_8 WHERE entry_id IN (14) ORDER BY id ASC; [0.0002]
SELECT SQL_CACHE * FROM sym_entries_data_51 WHERE entry_id IN (14) ORDER BY id ASC; [0.0001]
SELECT SQL_CACHE * FROM sym_entries_data_50 WHERE entry_id IN (14) ORDER BY id ASC; [0.0001]
SELECT SQL_CACHE * FROM sym_entries_data_32 WHERE entry_id IN (14) ORDER BY id ASC; [0.0001]
SELECT SQL_CACHE id, element_name, type, location FROM sym_fields WHERE parent_section = '1' ORDER BY sortorder ASC; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.id = '1' LIMIT 1; [0.0001]
SELECT SQL_CACHE * FROM sym_fields_input WHERE field_id = '1' LIMIT 1; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.id = '8' LIMIT 1; [0.0002]
SELECT SQL_CACHE * FROM sym_fields_order_entries WHERE field_id = '8' LIMIT 1; [0.0003]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.id = '2' LIMIT 1; [0.0002]
SELECT SQL_CACHE * FROM sym_fields_input WHERE field_id = '2' LIMIT 1; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.id = '3' LIMIT 1; [0.0002]
SELECT SQL_CACHE * FROM sym_fields_textarea WHERE field_id = '3' LIMIT 1; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.id = '50' LIMIT 1; [0.0003]
SELECT SQL_CACHE * FROM sym_fields_input WHERE field_id = '50' LIMIT 1; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.id = '51' LIMIT 1; [0.0002]
SELECT SQL_CACHE * FROM sym_fields_input WHERE field_id = '51' LIMIT 1; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.id = '4' LIMIT 1; [0.0002]
SELECT SQL_CACHE * FROM sym_fields_checkbox WHERE field_id = '4' LIMIT 1; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.id = '32' LIMIT 1; [0.0002]
SELECT SQL_CACHE * FROM sym_fields_checkbox WHERE field_id = '32' LIMIT 1; [0.0002]
SELECT SQL_CACHE t1.* FROM sym_fields as t1 WHERE 1 AND t1.id = '7' LIMIT 1; [0.0002]
SELECT SQL_CACHE * FROM sym_fields_image_upload WHERE field_id = '7' LIMIT 1; [0.0003]

Remote Images

This is a feature request:
Would it be possible to make this field handle remote images?
Sounds strange? Okay โ€ฆ

The Background

We have a site that grabs Facebook feeds and imports entries using XML Importer. Due to the way Facebook handles their media attachments, links to images change after a while which results invalid references in our imported entries. If we could store a copy on our own server, everything would continue to work as expected.

The Idea

If the extension receives a link to a remote ressource instead of a local image, it first stores a copy on the server and then continues as usual.

Symphony 2.4

Extension doesn't work in Symphony 2.4, will there be an update?

Symphony Recoverable Error: Argument 1 passed to fieldImage_upload::getChildrenWithClass() must be an instance of XMLElement, string given, called in extensions\image_upload\fields\field.image_upload.php on line 525 and defined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.