From 9478ccb8187e46b117a61aabeef827ab3927cd3e Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Mon, 30 Sep 2013 22:29:02 +0000 Subject: [PATCH] Changes made after feature review --- include/ajax.config.php | 20 +++++++++-------- include/ajax.kbase.php | 4 +++- include/class.attachment.php | 19 ++++++++-------- include/class.canned.php | 6 ++--- include/class.category.php | 4 ++-- include/class.draft.php | 22 +++++++++---------- include/class.faq.php | 6 ++--- include/class.format.php | 13 +++++++---- include/client/view.inc.php | 5 +---- include/html2text.php | 2 +- include/i18n/en_US/email_template_group.yaml | 2 +- .../en_US/templates/email/ticket.alert.yaml | 2 +- .../templates/email/ticket.autoreply.yaml | 2 +- .../en_US/templates/email/ticket.notice.yaml | 2 +- .../en_US/templates/email/ticket.reply.yaml | 5 ++--- .../en_US/templates/email/transfer.alert.yaml | 2 +- include/staff/cannedresponse.inc.php | 3 ++- include/staff/category.inc.php | 4 +++- include/staff/faq-category.inc.php | 2 +- include/staff/faq.inc.php | 4 +++- include/staff/tpl.inc.php | 2 +- ....patch.sql => d51f303a-ec19794f.patch.sql} | 4 ++-- .../streams/core/d51f303a-ec19794f.task.php | 15 +++++++++++++ js/osticket.js | 11 +++++----- js/redactor-osticket.js | 14 ++++++++---- scp/js/ticket.js | 9 ++++---- 26 files changed, 105 insertions(+), 79 deletions(-) rename include/upgrader/streams/core/{16fcef4a-ec19794f.patch.sql => d51f303a-ec19794f.patch.sql} (97%) create mode 100644 include/upgrader/streams/core/d51f303a-ec19794f.task.php diff --git a/include/ajax.config.php b/include/ajax.config.php index 5a1ff5420..7f2be0617 100644 --- a/include/ajax.config.php +++ b/include/ajax.config.php @@ -23,10 +23,11 @@ class ConfigAjaxAPI extends AjaxController { global $cfg; $config=array( - 'lock_time' => ($cfg->getLockTime()*3600), - 'max_file_uploads'=> (int) $cfg->getStaffMaxFileUploads(), - 'html_thread' => (bool) $cfg->isHtmlThreadEnabled(), - ); + 'lock_time' => ($cfg->getLockTime()*3600), + 'max_file_uploads'=> (int) $cfg->getStaffMaxFileUploads(), + 'html_thread' => (bool) $cfg->isHtmlThreadEnabled(), + 'allow_attachments' => (bool) $cfg->allowAttachments(), + ); return $this->json_encode($config); } @@ -34,11 +35,12 @@ class ConfigAjaxAPI extends AjaxController { global $cfg; $config=array( - 'file_types' => $cfg->getAllowedFileTypes(), - 'max_file_size' => (int) $cfg->getMaxFileSize(), - 'max_file_uploads'=> (int) $cfg->getClientMaxFileUploads(), - 'html_thread' => (bool) $cfg->isHtmlThreadEnabled(), - ); + 'allow_attachments' => (bool) $cfg->allowOnlineAttachments, + 'file_types' => $cfg->getAllowedFileTypes(), + 'max_file_size' => (int) $cfg->getMaxFileSize(), + 'max_file_uploads'=> (int) $cfg->getClientMaxFileUploads(), + 'html_thread' => (bool) $cfg->isHtmlThreadEnabled(), + ); return $this->json_encode($config); } diff --git a/include/ajax.kbase.php b/include/ajax.kbase.php index adf136ffc..ba0cf1d1c 100644 --- a/include/ajax.kbase.php +++ b/include/ajax.kbase.php @@ -41,8 +41,10 @@ class KbaseAjaxAPI extends AjaxController { : $canned->getResponseWithImages(); $resp['files'] = $canned->attachments->getSeparates(); - if (!$cfg->isHtmlThreadEnabled()) + if (!$cfg->isHtmlThreadEnabled()) { $resp['response'] = convert_html_to_text($resp['response'], 90); + $resp['files'] += $canned->attachments->getInlines(); + } $response = $this->json_encode($resp); break; diff --git a/include/class.attachment.php b/include/class.attachment.php index 36d197bb5..a46028d83 100644 --- a/include/class.attachment.php +++ b/include/class.attachment.php @@ -157,25 +157,26 @@ class GenericAttachments { function _getList($separate=false, $inlines=false) { if(!isset($this->attachments)) { $this->attachments = array(); - $sql='SELECT f.id, f.size, f.hash, f.name ' + $sql='SELECT f.id, f.size, f.hash, f.name, a.inline ' .' FROM '.FILE_TABLE.' f ' .' INNER JOIN '.ATTACHMENT_TABLE.' a ON(f.id=a.file_id) ' .' WHERE a.`type`='.db_input($this->getType()) .' AND a.object_id='.db_input($this->getId()); - if ($inlines && !$separate) - $sql .= ' AND a.inline'; - elseif (!$inlines && $separate) - $sql .= ' AND NOT a.inline'; - if(($res=db_query($sql)) && db_num_rows($res)) { while($rec=db_fetch_array($res)) { - $rec['key'] = md5($rec['id'].session_id().$rec['hash']); - $rec['file_id'] = $rec['id']; $this->attachments[] = $rec; } } } - return $this->attachments; + $attachments = array(); + foreach ($this->attachments as $a) { + if ($a['inline'] != $separate || $a['inline'] == $inlines) { + $a['key'] = md5($a['id'].session_id().$a['hash']); + $a['file_id'] = $a['id']; + $attachments[] = $a; + } + } + return $attachments; } function delete($file_id) { diff --git a/include/class.canned.php b/include/class.canned.php index d67e8a03e..b8aa297d7 100644 --- a/include/class.canned.php +++ b/include/class.canned.php @@ -186,7 +186,6 @@ class Canned { global $cfg; $vars['title']=Format::striptags(trim($vars['title'])); - $vars['notes']=Format::striptags(trim($vars['notes'])); if($id && $id!=$vars['id']) $errors['err']='Internal error. Try again'; @@ -207,9 +206,8 @@ class Canned { ',dept_id='.db_input($vars['dept_id']?$vars['dept_id']:0). ',isenabled='.db_input($vars['isenabled']). ',title='.db_input($vars['title']). - ',response='.db_input(Format::sanitize($vars['response'], - !$cfg->isHtmlThreadEnabled())). - ',notes='.db_input($vars['notes']); + ',response='.db_input(Format::sanitize($vars['response'])). + ',notes='.db_input(Format::sanitize($vars['notes'])); if($id) { $sql='UPDATE '.CANNED_TABLE.' SET '.$sql.' WHERE canned_id='.db_input($id); diff --git a/include/class.category.php b/include/class.category.php index 622096737..ba705b412 100644 --- a/include/class.category.php +++ b/include/class.category.php @@ -143,8 +143,8 @@ class Category { $sql=' updated=NOW() '. ',ispublic='.db_input(isset($vars['ispublic'])?$vars['ispublic']:0). ',name='.db_input($vars['name']). - ',description='.db_input(Format::safe_html($vars['description'])). - ',notes='.db_input($vars['notes']); + ',description='.db_input(Format::sanitize($vars['description'])). + ',notes='.db_input(Format::sanitize($vars['notes'])); if($id) { $sql='UPDATE '.FAQ_CATEGORY_TABLE.' SET '.$sql.' WHERE category_id='.db_input($id); diff --git a/include/class.draft.php b/include/class.draft.php index b183736c7..6796428b6 100644 --- a/include/class.draft.php +++ b/include/class.draft.php @@ -25,20 +25,18 @@ class Draft { function getNamespace() { return $this->ht['namespace']; } function getAttachmentIds($body=false) { - if (!isset($this->_attachments)) { - $this->_attachments = array(); - if (!$body) - $body = $this->getBody(); - $body = Format::localizeInlineImages($body); - $matches = array(); - if (preg_match_all('/"cid:([\\w.-]{32})"/', $body, $matches)) { - foreach ($matches[1] as $hash) { - if ($file_id = AttachmentFile::getIdByHash($hash)) - $this->_attachments[] = $file_id; - } + $attachments = array(); + if (!$body) + $body = $this->getBody(); + $body = Format::localizeInlineImages($body); + $matches = array(); + if (preg_match_all('/"cid:([\\w.-]{32})"/', $body, $matches)) { + foreach ($matches[1] as $hash) { + if ($file_id = AttachmentFile::getIdByHash($hash)) + $attachments[] = $file_id; } } - return $this->_attachments; + return $attachments; } /* diff --git a/include/class.faq.php b/include/class.faq.php index 4069ebd7b..7cb3c9a95 100644 --- a/include/class.faq.php +++ b/include/class.faq.php @@ -35,8 +35,8 @@ class FAQ { .' FROM '.FAQ_TABLE.' faq ' .' LEFT JOIN '.FAQ_CATEGORY_TABLE.' cat ON(cat.category_id=faq.category_id) ' .' LEFT JOIN '.ATTACHMENT_TABLE.' attach - ON(attach.object_id=faq.faq_id AND attach.`type`=\'F\') ' - .' WHERE attach.inline=0 AND faq.faq_id='.db_input($id) + ON(attach.object_id=faq.faq_id AND attach.`type`=\'F\' AND attach.inline=0) ' + .' WHERE faq.faq_id='.db_input($id) .' GROUP BY faq.faq_id'; if (!($res=db_query($sql)) || !db_num_rows($res)) @@ -306,7 +306,7 @@ class FAQ { .', answer='.db_input(Format::sanitize($vars['answer'], false)) .', category_id='.db_input($vars['category_id']) .', ispublished='.db_input(isset($vars['ispublished'])?$vars['ispublished']:0) - .', notes='.db_input($vars['notes']); + .', notes='.db_input(Format::sanitize($vars['notes'])); if($id) { $sql='UPDATE '.FAQ_TABLE.' SET '.$sql.' WHERE faq_id='.db_input($id); diff --git a/include/class.format.php b/include/class.format.php index a327f1289..251b1b1f9 100644 --- a/include/class.format.php +++ b/include/class.format.php @@ -197,7 +197,7 @@ class Format { } //Format text for display.. - function display($text) { + function display($text, $inline_images=true) { global $cfg; //make urls clickable. @@ -212,14 +212,19 @@ class Format { # $text); // Make showing offsite images optional - return preg_replace_callback('/<img ([^>]*)(src="http.+)\/>/', + $text = preg_replace_callback('/<img ([^>]*)(src="http[^"]+")([^>]*)\/>/', function($match) { // Drop embedded classes -- they don't refer to ours $match = preg_replace('/class="[^"]*"/', '', $match); - return sprintf('<div %s class="non-local-image" data-%s></div>', - $match[1], $match[2]); + return sprintf('<div %s class="non-local-image" data-%s %s></div>', + $match[1], $match[2], $match[3]); }, $text); + + if ($inline_images) + return self::viewableImages($text); + + return $text; } function striptags($var, $decode=true) { diff --git a/include/client/view.inc.php b/include/client/view.inc.php index 97202f4d0..0b6950c39 100644 --- a/include/client/view.inc.php +++ b/include/client/view.inc.php @@ -107,10 +107,7 @@ if($ticket->getThreadCount() && ($thread=$ticket->getClientThread())) { <input type="hidden" name="a" value="reply"> <table border="0" cellspacing="0" cellpadding="3" width="800"> <tr> - <td width="160"> - <label>Message:</label> - </td> - <td width="640"> + <td colspan="2"> <?php if($ticket->isClosed()) { $msg='<b>Ticket will be reopened on message post</b>'; diff --git a/include/html2text.php b/include/html2text.php index fb84a7b38..51137d002 100644 --- a/include/html2text.php +++ b/include/html2text.php @@ -392,7 +392,7 @@ class HtmlImgElement extends HtmlInlineElement { if ($title) $title = ": $title"; $alt = $this->node->getAttribute("alt"); - return "[$alt$title] "; + return "[image:$alt$title] "; } function getWeight() { return parent::getWeight() + 4; } } diff --git a/include/i18n/en_US/email_template_group.yaml b/include/i18n/en_US/email_template_group.yaml index 41c5aca70..4a76150ff 100644 --- a/include/i18n/en_US/email_template_group.yaml +++ b/include/i18n/en_US/email_template_group.yaml @@ -14,6 +14,6 @@ # --- - isactive: 1 - name: osTicket Default Template + name: osTicket Default Template (HTML) notes: | Default osTicket templates diff --git a/include/i18n/en_US/templates/email/ticket.alert.yaml b/include/i18n/en_US/templates/email/ticket.alert.yaml index 702838044..97e2a5dfb 100644 --- a/include/i18n/en_US/templates/email/ticket.alert.yaml +++ b/include/i18n/en_US/templates/email/ticket.alert.yaml @@ -49,5 +49,5 @@ body: | <em>Your friendly Customer Support System <br/> <a href="http://osticket.com/"><img width="126" height="23" - alt="Powered By osTicket" src="cid:QURBOEMxRUY4QjcyRTFFMyIvPiA8L3Jk"/></a> + alt="Powered By osTicket" src="cid:b56944cb4722cc5cda9d1e23a3ea7fbc"/></a> </p> diff --git a/include/i18n/en_US/templates/email/ticket.autoreply.yaml b/include/i18n/en_US/templates/email/ticket.autoreply.yaml index 20a74ca7e..19f833ea5 100644 --- a/include/i18n/en_US/templates/email/ticket.autoreply.yaml +++ b/include/i18n/en_US/templates/email/ticket.autoreply.yaml @@ -75,7 +75,7 @@ body: | support requests and responses.</span> </p> <p> - <span style="color: rgb(127, 127, 127);">Visit our</span> + <span style="color: rgb(127, 127, 127);">Visit our </span> <a href="%{url}/kb"><span style="color: rgb(84, 141, 212);">knowledgebase</span></a> </p> diff --git a/include/i18n/en_US/templates/email/ticket.notice.yaml b/include/i18n/en_US/templates/email/ticket.notice.yaml index b1a8a788d..3bcf76611 100644 --- a/include/i18n/en_US/templates/email/ticket.notice.yaml +++ b/include/i18n/en_US/templates/email/ticket.notice.yaml @@ -19,7 +19,7 @@ body: | <td style="vertical-align: middle; border-bottom: 1px solid #ddd; height: 48pt"> <span style="color: rgb(127, 127, 127); font-family: Georgia; - font-size: 28pt; font-weight: normal;">We Hear You</span> + font-size: 28pt; font-weight: normal;">We're Here For You</span> </td> <td style="border-bottom: 1px solid #ddd;"> <img src="cid:6fe1efdea357534d238b86e7860a7c5a" width="94" diff --git a/include/i18n/en_US/templates/email/ticket.reply.yaml b/include/i18n/en_US/templates/email/ticket.reply.yaml index ad343e688..a73a75ff0 100644 --- a/include/i18n/en_US/templates/email/ticket.reply.yaml +++ b/include/i18n/en_US/templates/email/ticket.reply.yaml @@ -10,13 +10,12 @@ notes: | Sent to users when a staff members makes a reply to their ticket. Replies are only generated by staff members. -subject: | - Re\: %{ticket.subject} +subject: "Re: %{ticket.subject}" body: | <img src="cid:6fe1efdea357534d238b86e7860a7c5a" alt="osTicket Logo (kangaroo)" width="113" height="64" style="float: right; width: 113px; margin: 0px 0px 10px 10px;"> <h3><span style="color: rgb(127, 127, 127); font-weight: normal; - font-family: Georgia; font-size: 30pt">Title text here</span></h3> + font-family: Georgia; font-size: 30pt">We're Here For You</span></h3> <p> <strong>Dear %{ticket.name},</strong> </p> diff --git a/include/i18n/en_US/templates/email/transfer.alert.yaml b/include/i18n/en_US/templates/email/transfer.alert.yaml index aa9b68d21..43d293931 100644 --- a/include/i18n/en_US/templates/email/transfer.alert.yaml +++ b/include/i18n/en_US/templates/email/transfer.alert.yaml @@ -30,5 +30,5 @@ body: | <em>Your friendly Customer Support System <br/> <a href="http://osticket.com/"><img width="126" height="23" - alt="Powered By osTicket" src="cid:QURBOEMxRUY4QjcyRTFFMyIvPiA8L3Jk"/></a> + alt="Powered By osTicket" src="cid:b56944cb4722cc5cda9d1e23a3ea7fbc"/></a> </p> diff --git a/include/staff/cannedresponse.inc.php b/include/staff/cannedresponse.inc.php index f540c3f7d..4e38ff964 100644 --- a/include/staff/cannedresponse.inc.php +++ b/include/staff/cannedresponse.inc.php @@ -11,6 +11,7 @@ if($canned && $_REQUEST['a']!='add'){ $qstr.='&id='.$canned->getId(); // Replace cid: scheme with downloadable URL for inline images $info['response'] = $canned->getResponseWithImages(); + $info['notes'] = Format::viewableImages($info['notes']); }else { $title='Add New Canned Response'; $action='create'; @@ -75,7 +76,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); <br><br><div style="margin-bottom:0.5em"><b>Canned Response</b> <font class="error">* <?php echo $errors['response']; ?></font> (<a class="tip" href="ticket_variables">Supported Variables</a>) </div> - <textarea name="response ifhtml draft draft-delete" cols="21" rows="12" + <textarea name="response" class="richtext draft draft-delete" cols="21" rows="12" data-draft-namespace="canned" data-draft-object-id="<?php if (isset($canned)) echo $canned->getId(); ?>" style="width:98%;" class="richtext draft"><?php diff --git a/include/staff/category.inc.php b/include/staff/category.inc.php index f5a153dbc..76659bde6 100644 --- a/include/staff/category.inc.php +++ b/include/staff/category.inc.php @@ -8,6 +8,7 @@ if($category && $_REQUEST['a']!='add'){ $submit_text='Save Changes'; $info=$category->getHashtable(); $info['id']=$category->getId(); + $info['notes'] = Format::viewableImages($category->getNotes()); $qstr.='&id='.$category->getId(); }else { $title='Add New Category'; @@ -67,7 +68,8 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </tr> <tr> <td colspan=2> - <textarea name="notes" cols="21" rows="8" style="width: 80%;"><?php echo $info['notes']; ?></textarea> + <textarea class="richtext no-bar" name="notes" cols="21" + rows="8" style="width: 80%;"><?php echo $info['notes']; ?></textarea> </td> </tr> </tbody> diff --git a/include/staff/faq-category.inc.php b/include/staff/faq-category.inc.php index 8bf9e7a9d..39f70e688 100644 --- a/include/staff/faq-category.inc.php +++ b/include/staff/faq-category.inc.php @@ -14,7 +14,7 @@ if(!defined('OSTSTAFFINC') || !$category || !$thisstaff) die('Access Denied'); <time>Last updated <?php echo Format::db_daydatetime($category->getUpdateDate()); ?></time> </div> <div class="cat-desc"> -<?php echo Format::safe_html($category->getDescription()); ?> +<?php echo Format::display($category->getDescription()); ?> </div> <?php if($thisstaff->canManageFAQ()) { diff --git a/include/staff/faq.inc.php b/include/staff/faq.inc.php index b24ca665a..e700bd429 100644 --- a/include/staff/faq.inc.php +++ b/include/staff/faq.inc.php @@ -10,6 +10,7 @@ if($faq){ $info['id']=$faq->getId(); $info['topics']=$faq->getHelpTopicsIds(); $info['answer']=$faq->getAnswer(); + $info['notes']=Format::viewableImages($faq->getNotes()); $qstr='id='.$faq->getId(); }else { $title='Add New FAQ'; @@ -144,7 +145,8 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </tr> <tr> <td colspan=2> - <textarea name="notes" cols="21" rows="8" style="width: 80%;"><?php echo $info['notes']; ?></textarea> + <textarea class="richtext no-bar" name="notes" cols="21" + rows="8" style="width: 80%;"><?php echo $info['notes']; ?></textarea> </td> </tr> </tbody> diff --git a/include/staff/tpl.inc.php b/include/staff/tpl.inc.php index 9527b5a34..b4dd33054 100644 --- a/include/staff/tpl.inc.php +++ b/include/staff/tpl.inc.php @@ -15,7 +15,7 @@ if (is_a($template, EmailTemplateGroup)) { $default = @$template->getMsgTemplate($selected); if ($default) { $info['subject'] = $default->getSubject(); - $info['body'] = $default->getBody(); + $info['body'] = Format::viewableImages($default->getBody()); } } else { // Template edit diff --git a/include/upgrader/streams/core/16fcef4a-ec19794f.patch.sql b/include/upgrader/streams/core/d51f303a-ec19794f.patch.sql similarity index 97% rename from include/upgrader/streams/core/16fcef4a-ec19794f.patch.sql rename to include/upgrader/streams/core/d51f303a-ec19794f.patch.sql index bae4ac715..52449d9aa 100644 --- a/include/upgrader/streams/core/16fcef4a-ec19794f.patch.sql +++ b/include/upgrader/streams/core/d51f303a-ec19794f.patch.sql @@ -103,10 +103,10 @@ UPDATE `%TABLE_PREFIX%team` -- Migrate canned responses to HTML UPDATE `%TABLE_PREFIX%canned_response` - SET `body` = REPLACE('\n', '<br/>', + SET `notes` = REPLACE('\n', '<br/>', REPLACE('<', '<', REPLACE('>', '>', - REPLACE('&', '&', `body`)))), + REPLACE('&', '&', `notes`)))), `response` = REPLACE('\n', '<br/>', REPLACE('<', '<', REPLACE('>', '>', diff --git a/include/upgrader/streams/core/d51f303a-ec19794f.task.php b/include/upgrader/streams/core/d51f303a-ec19794f.task.php new file mode 100644 index 000000000..2786e3b10 --- /dev/null +++ b/include/upgrader/streams/core/d51f303a-ec19794f.task.php @@ -0,0 +1,15 @@ +<?php + +class NewHtmlTemplate extends MigrationTask { + var $description = "Adding new super-awesome HTML templates"; + + function run($runtime) { + $i18n = new Internationalization('en_US'); + $tpls = $i18n->getTemplate('email_template_group.yaml')->getData(); + foreach ($tpls as $t) + EmailTemplateGroup::create($t); + } +} +return 'NewHtmlTemplate'; + +?> diff --git a/js/osticket.js b/js/osticket.js index 653af24ba..58cb765eb 100644 --- a/js/osticket.js +++ b/js/osticket.js @@ -110,14 +110,13 @@ $(document).ready(function(){ showImagesInline = function(urls, thread_id) { var selector = (thread_id == undefined) - ? '.thread-body img[src^=cid]' - : '.thread-body#thread-id-'+thread_id+' img[src^=cid]'; + ? '.thread-body img[data-cid]' + : '.thread-body#thread-id-'+thread_id+' img[data-cid]'; $(selector).each(function(i, el) { - var hash = $(el).attr('src').slice(4), - info = urls[hash], + var cid = $(el).data('cid'), + info = urls[cid], e = $(el); - if (info && e.attr('src') == 'cid:' + hash) { - e.attr('src', info.url); + if (info) { // Add a hover effect with the filename var caption = $('<div class="image-hover">') .hover( diff --git a/js/redactor-osticket.js b/js/redactor-osticket.js index a9c68e0b5..96c8204c6 100644 --- a/js/redactor-osticket.js +++ b/js/redactor-osticket.js @@ -74,10 +74,16 @@ RedactorPlugins.draft = { .val(data.draft_id); this.draft_id = data.draft_id; - this.opts.clipboardUploadUrl = - this.opts.imageUpload = - 'ajax.php/draft/'+data.draft_id+'/attach'; - this.opts.imageUploadErrorCallback = this.displayError; + var self = this; + getConfig().then(function(c) { + console.log(c); + if (c.allow_attachments) { + self.opts.clipboardUploadUrl = + self.opts.imageUpload = + 'ajax.php/draft/'+data.draft_id+'/attach'; + self.opts.imageUploadErrorCallback = self.displayError; + } + }); this.opts.autosave = 'ajax.php/draft/'+data.draft_id; }, diff --git a/scp/js/ticket.js b/scp/js/ticket.js index 451c7675a..cbe042f44 100644 --- a/scp/js/ticket.js +++ b/scp/js/ticket.js @@ -390,6 +390,7 @@ jQuery(function($) { showNonLocalImage(img); $(img).removeClass('non-local-image') // Remove placeholder sizing + .css({'display':'inline-block'}) .width('auto') .height('auto') .removeAttr('width') @@ -405,15 +406,13 @@ jQuery(function($) { var $img = $(img); // Save a copy of the original styling $img.data('style', $img.attr('style')); + $img.removeAttr('style'); // If the image has a 'height' attribute, use it, otherwise, use // 40px - if ($img.attr('height')) - $img.height($img.attr('height')); - else - $img.height('40px'); + $img.height(($img.attr('height') || '40') + 'px'); // Ensure the image placeholder is visible width-wise if (!$img.width()) - $img.width('80px'); + $img.width(($img.attr('width') || '80') + 'px'); // TODO: Add a hover-button to show just one image }); }); -- GitLab