diff --git a/assets/image_preview.js b/assets/image_preview.js index 61b571b..f3f208e 100644 --- a/assets/image_preview.js +++ b/assets/image_preview.js @@ -20,7 +20,8 @@ resize: 1, position: 5, absolute: false, - isDefault: true + isDefault: true, + isJIT: false }; var params = { @@ -33,7 +34,6 @@ var SVG = '.svg'; var createUrl = function (imgSrc, params) { - var newSrc = 'image/{resize}/{width}/{height}{position}'; newSrc = newSrc.replace('{resize}', params.resize); @@ -66,7 +66,6 @@ } if (!!node.length) { - var width = parseInt(node.attr('data-width'), 10), height = parseInt(node.attr('data-height'), 10), @@ -80,9 +79,11 @@ params.position = position || params.position; params.absolute = absolute || params.absolute; params.isDefault = false; + params.isJIT = true; return false; //exit for } + return true; }); @@ -134,7 +135,7 @@ } var p = getParameters(classes, defaults); - var url = createUrl(imgSrc, p); + var url = (p.isJIT) ? createUrl(imgSrc, p) : imgSrc; // bind load event img.addEventListener('load', function (e) { _imageLoaded(e, p, this.src); }); diff --git a/extension.meta.xml b/extension.meta.xml index 6c40fc9..4e13ddf 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -1,57 +1,62 @@ - - - Image Preview - Replaces the textual link to the image with the real image - https://github.com/Solutions-Nitriques/image_preview - http://getsymphony.com/discuss/thread/71485/ - https://github.com/Solutions-Nitriques/image_preview/issues - - Interface - Field - Preview - - - - Deux Huit Huit - https://deuxhuithuit.com/ - - - - - - Add support for multi-upload field - - - - Supported on PHP 7 - - Fixed parameters to fit the parent method - - - - Added missing .field-multilingual_upload selector - - - - UI (css) fixes - - - - Added support for svg - - Do not request any file if there is already an image in the link - - - - Compatibility for custom url: assets are now loaded using full absolute url - - Support for Association Drawer - - - - Compatibility with multilingual fields (more than one file/link) - - - - Added a Image Preview Settings field : - It is now possible to customize how images are previewed. - You can change those settings by adding one or more `Image Preview Settings` field to you section. - - Minor UI updates - - - - Compatibility with Symphony 2.3 - - - - Initial release - - - \ No newline at end of file + + + Image Preview + Replaces the textual link to the image with the real image + https://github.com/Solutions-Nitriques/image_preview + http://getsymphony.com/discuss/thread/71485/ + https://github.com/Solutions-Nitriques/image_preview/issues + + Interface + Field + Preview + + + + Deux Huit Huit + https://deuxhuithuit.com/ + + + + + - Update for Symphony 4.x + - Code refactoring for Database and EQFA + - Replace deprecated method fetch() by select() + + + - Add support for multi-upload field + + + - Supported on PHP 7 + - Fixed parameters to fit the parent method + + + - Added missing .field-multilingual_upload selector + + + - UI (css) fixes + + + - Added support for svg + - Do not request any file if there is already an image in the link + + + - Compatibility for custom url: assets are now loaded using full absolute url + - Support for Association Drawer + + + - Compatibility with multilingual fields (more than one file/link) + + + - Added a Image Preview Settings field : + It is now possible to customize how images are previewed. + You can change those settings by adding one or more `Image Preview Settings` field to you section. + - Minor UI updates + + + - Compatibility with Symphony 2.3 + + + - Initial release + + + diff --git a/fields/field.image_preview_settings.php b/fields/field.image_preview_settings.php index e879f6d..d440512 100644 --- a/fields/field.image_preview_settings.php +++ b/fields/field.image_preview_settings.php @@ -249,12 +249,19 @@ public function commit() $settings['entry-absolute'] = empty($e_absolute) ? 'no' : $e_absolute; // DB - $tbl = self::FIELD_TBL_NAME; - - Symphony::Database()->query("DELETE FROM `$tbl` WHERE `field_id` = '$id' LIMIT 1"); + Symphony::Database() + ->delete(self::FIELD_TBL_NAME) + ->where(['field_id' => $id]) + ->limit(1) + ->execute() + ->success(); // return if the SQL command was successful - return Symphony::Database()->insert($settings, $tbl); + return Symphony::Database() + ->insert(self::FIELD_TBL_NAME) + ->values($settings) + ->execute() + ->success(); } @@ -297,8 +304,13 @@ private function convertHandlesIntoIds($handles) $parent_section = $this->get('parent_section'); foreach ($aHandles as $handle) { - $where = "AND t1.`element_name` = '$handle'"; - $field = FieldManager::fetch(null, $parent_section, 'ASC', 'sortorder', null, null, $where); + $field = (new FieldManager) + ->select() + ->sort('sortorder', 'asc') + ->section($parent_section) + ->where(['t1.element_name' => $handle]) + ->execute() + ->next(); $fieldId = array_keys($field); $fieldId = $fieldId[0]; @@ -490,14 +502,22 @@ public function tearDown() */ public function createTable() { - return Symphony::Database()->query( - "CREATE TABLE IF NOT EXISTS `tbl_entries_data_" . $this->get('id') . "` ( - `id` int(11) unsigned NOT NULL auto_increment, - `entry_id` int(11) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `entry_id` (`entry_id`) - ) TYPE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;" - ); + return Symphony::Database() + ->create('tbl_entries_data_' . $this->get('id')) + ->ifNotExists() + ->fields([ + 'id' => [ + 'type' => 'int(11)', + 'auto' => true, + ], + 'entry_id' => 'int(11)', + ]) + ->keys([ + 'id' => 'primary', + 'entry_id' => 'key', + ]) + ->execute() + ->success(); } /** @@ -505,27 +525,65 @@ public function createTable() */ public static function createFieldTable() { - $tbl = self::FIELD_TBL_NAME; - - return Symphony::Database()->query(" - CREATE TABLE IF NOT EXISTS `$tbl` ( - `id` int(11) unsigned NOT NULL auto_increment, - `field_id` int(11) unsigned NOT NULL, - `field-handles` varchar(255) NOT NULL, - `table-width` int(11) unsigned NULL, - `table-height` int(11) unsigned NULL, - `table-resize` int(11) unsigned NULL, - `table-position` int(11) unsigned NULL, - `table-absolute` enum('yes','no') NOT NULL DEFAULT 'no', - `entry-width` int(11) unsigned NULL, - `entry-height` int(11) unsigned NULL, - `entry-resize` int(11) unsigned NULL, - `entry-position` int(11) unsigned NULL, - `entry-absolute` enum('yes','no') NOT NULL DEFAULT 'no', - PRIMARY KEY (`id`), - KEY `field_id` (`field_id`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - "); + return Symphony::Database() + ->create(self::FIELD_TBL_NAME) + ->ifNotExists() + ->fields([ + 'id' => [ + 'type' => 'int(11)', + 'auto' => true, + ], + 'field_id' => 'int(11)', + 'field-handles' => 'varchar(255)', + 'table-width' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'table-height' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'table-resize' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'table-position' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'table-absolute' => [ + 'type' => 'enum', + 'values' => ['yes','no'], + 'default' => 'no', + ], + 'entry-width' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'entry-height' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'entry-resize' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'entry-position' => [ + 'type' => 'int(11)', + 'null' => true, + ], + 'entry-absolute' => [ + 'type' => 'enum', + 'values' => ['yes','no'], + 'default' => 'no', + ], + ]) + ->keys([ + 'id' => 'primary', + 'field_id' => 'key', + ]) + ->execute() + ->success(); } @@ -535,10 +593,10 @@ public static function createFieldTable() */ public static function deleteFieldTable() { - $tbl = self::FIELD_TBL_NAME; - - return Symphony::Database()->query(" - DROP TABLE IF EXISTS `$tbl` - "); + return Symphony::Database() + ->drop(self::FIELD_TBL_NAME) + ->ifExists() + ->execute() + ->success(); } }