Skip to content

Commit

Permalink
Add width definition of the inline image of payment slip in e-mail body
Browse files Browse the repository at this point in the history
  • Loading branch information
zeko868 committed Oct 11, 2020
1 parent 96a3f85 commit 994b8fa
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 27 deletions.
47 changes: 34 additions & 13 deletions languages/wooplatnica-croatia-hr.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Croatian payment slip generator for WooCommerce 1.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-03 20:39+0000\n"
"PO-Revision-Date: 2020-05-03 20:58+0000\n"
"POT-Creation-Date: 2020-10-11 14:41+0000\n"
"PO-Revision-Date: 2020-10-11 14:48+0000\n"
"Last-Translator: zeko868\n"
"Language-Team: Hrvatski\n"
"Language: hr\n"
Expand All @@ -13,7 +13,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Loco https://localise.biz/\n"
"X-Loco-Version: 2.3.1; wp-5.2.6"
"X-Loco-Version: 2.3.1; wp-5.4.2"

#: src/WC_Gateway_Wooplatnica.php:16
msgid "[CRO] Payment slip or mobile banking"
Expand Down Expand Up @@ -157,7 +157,7 @@ msgid "Intent code"
msgstr "Svrha plaćanja"

#: src/WC_Gateway_Wooplatnica.php:121 src/WC_Gateway_Wooplatnica.php:319
#: src/WC_Gateway_Wooplatnica.php:334 src/WC_Gateway_Wooplatnica.php:427
#: src/WC_Gateway_Wooplatnica.php:334 src/WC_Gateway_Wooplatnica.php:435
msgid "(undefined)"
msgstr "(nedefinirano)"

Expand Down Expand Up @@ -234,46 +234,67 @@ msgid "Type of the image with the generated payment slip"
msgstr "Format slike s generiranom općom uplatnicom"

#: src/WC_Gateway_Wooplatnica.php:375
msgid "Width of the inline image in e-mail message"
msgstr "Širina slike u tijelu e-mail poruke"

#: src/WC_Gateway_Wooplatnica.php:376
msgid ""
"Height is being scaled to width proportionally. Leave empty if you don't "
"want to specify dimensions of inline image. Not recommended since in some e-"
"mail clients like Windows 10 Mail UWP app the image would be shown in its "
"original size instead of maximum available space thus often causing the need "
"for using horizontal slider in order to see complete content of the e-mail "
"message."
msgstr ""
"Visina slike se proporcionalno prilagođava navedenoj širini. Ostavite ovo "
"polje praznim ukoliko ne želite specificirati dimenzije ugrađene slike. No "
"to se baš ne preporuča budući neki e-mail klijenti poput aplikacije Pošta iz "
"Windows 10 bi prikazali sliku u originalnim dimenzijama umjesto da ju "
"prilagode raspoloživom prostoru zbog čega bi korisnik trebao koristiti "
"horizontalne klizače kako bi bio u mogućnosti vidjeti sav sadržaj e-mail "
"poruke."

#: src/WC_Gateway_Wooplatnica.php:383
msgid "Display confirmation part"
msgstr "Prikaži potvrdni listić"

#: src/WC_Gateway_Wooplatnica.php:377
#: src/WC_Gateway_Wooplatnica.php:385
msgid "Display confirmation part of the payment slip"
msgstr "Prikaži potvrdni listić (desni dio) na općoj uplatnici"

#: src/WC_Gateway_Wooplatnica.php:381
#: src/WC_Gateway_Wooplatnica.php:389
msgid "Main font"
msgstr "Glavni font"

#: src/WC_Gateway_Wooplatnica.php:382
#: src/WC_Gateway_Wooplatnica.php:390
msgid ""
"Font being used for the text that won't be displayed in fields with cells "
"for each character"
msgstr ""
"Font koji će se primijeniti na tekst koji neće biti prikazan u poljima s "
"ćelijama za svaki pojedini znak"

#: src/WC_Gateway_Wooplatnica.php:387
#: src/WC_Gateway_Wooplatnica.php:395
msgid "proportional"
msgstr "proporcionalni"

#: src/WC_Gateway_Wooplatnica.php:388
#: src/WC_Gateway_Wooplatnica.php:396
msgid "monospaced"
msgstr "neproporcionalni"

#: src/Wooplatnica.php:60
#: src/Wooplatnica.php:64
msgid "payment-slip"
msgstr "uplatnica"

#: src/Wooplatnica.php:66
#: src/Wooplatnica.php:68
msgid "Problem loading image of payment slip"
msgstr "Problem kod učitavanja slike uplatnice"

#: src/Wooplatnica.php:78
#: src/Wooplatnica.php:86
msgid "Payment slip image"
msgstr "slika opće uplatnice"

#: src/Wooplatnica.php:79
#: src/Wooplatnica.php:87
msgid "Download payment slip"
msgstr "Preuzmi uplatnicu"

Expand Down
36 changes: 25 additions & 11 deletions languages/wooplatnica-croatia.pot
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Croatian payment slip generator for WooCommerce 1.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-03 20:43+0000\n"
"POT-Creation-Date: 2020-10-11 14:49+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: \n"
Expand Down Expand Up @@ -148,7 +148,7 @@ msgid "Intent code"
msgstr ""

#: src/WC_Gateway_Wooplatnica.php:121 src/WC_Gateway_Wooplatnica.php:319
#: src/WC_Gateway_Wooplatnica.php:334 src/WC_Gateway_Wooplatnica.php:427
#: src/WC_Gateway_Wooplatnica.php:334 src/WC_Gateway_Wooplatnica.php:435
msgid "(undefined)"
msgstr ""

Expand Down Expand Up @@ -223,44 +223,58 @@ msgid "Type of the image with the generated payment slip"
msgstr ""

#: src/WC_Gateway_Wooplatnica.php:375
msgid "Width of the inline image in e-mail message"
msgstr ""

#: src/WC_Gateway_Wooplatnica.php:376
msgid ""
"Height is being scaled to width proportionally. Leave empty if you don't "
"want to specify dimensions of inline image. Not recommended since in some e-"
"mail clients like Windows 10 Mail UWP app the image would be shown in its "
"original size instead of maximum available space thus often causing the need "
"for using horizontal slider in order to see complete content of the e-mail "
"message."
msgstr ""

#: src/WC_Gateway_Wooplatnica.php:383
msgid "Display confirmation part"
msgstr ""

#: src/WC_Gateway_Wooplatnica.php:377
#: src/WC_Gateway_Wooplatnica.php:385
msgid "Display confirmation part of the payment slip"
msgstr ""

#: src/WC_Gateway_Wooplatnica.php:381
#: src/WC_Gateway_Wooplatnica.php:389
msgid "Main font"
msgstr ""

#: src/WC_Gateway_Wooplatnica.php:382
#: src/WC_Gateway_Wooplatnica.php:390
msgid ""
"Font being used for the text that won't be displayed in fields with cells "
"for each character"
msgstr ""

#: src/WC_Gateway_Wooplatnica.php:387
#: src/WC_Gateway_Wooplatnica.php:395
msgid "proportional"
msgstr ""

#: src/WC_Gateway_Wooplatnica.php:388
#: src/WC_Gateway_Wooplatnica.php:396
msgid "monospaced"
msgstr ""

#: src/Wooplatnica.php:60
#: src/Wooplatnica.php:64
msgid "payment-slip"
msgstr ""

#: src/Wooplatnica.php:66
#: src/Wooplatnica.php:68
msgid "Problem loading image of payment slip"
msgstr ""

#: src/Wooplatnica.php:78
#: src/Wooplatnica.php:86
msgid "Payment slip image"
msgstr ""

#: src/Wooplatnica.php:79
#: src/Wooplatnica.php:87
msgid "Download payment slip"
msgstr ""

Expand Down
10 changes: 9 additions & 1 deletion src/WC_Gateway_Wooplatnica.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,16 @@ public function init_form_fields()
'gif' => 'gif',
'bmp' => 'bmp'
),
'desc_type' => true
'desc_tip' => true
),
'payment_slip_email_width' => array(
'title' => __( 'Width of the inline image in e-mail message', $this->id ),
'description' => __( 'Height is being scaled to width proportionally. Leave empty if you don\'t want to specify dimensions of inline image. Not recommended since in some e-mail clients like Windows 10 Mail UWP app the image would be shown in its original size instead of maximum available space thus often causing the need for using horizontal slider in order to see complete content of the e-mail message.', $this->id ),
'type' => 'text',
'css' => 'width: 3em;',
'default' => '640',
'desc_tip' => true
),
'display_confirmation_part' => array(
'title' => __( 'Display confirmation part', $this->id ),
'type' => 'checkbox',
Expand Down
11 changes: 9 additions & 2 deletions src/Wooplatnica.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ private function display_payment_slip($order, $is_for_sending) {
'display_confirmation_part' => 'yes',
'payment_slip_type' => 'national',
'main_font' => 'proportional',
'output_image_type' => 'png'
'output_image_type' => 'png',
'payment_slip_email_width' => '640'
);
$this->options = array_merge($default_options, $this->options); // this is useful because after updating plugin, options that didn't exist in previous version of plugin are not yet stored in the database, i.e. when those options would be fetched, their values would be null even if those newly defined options have defined default values in WC_Gateway_Wooplatnica.php, what resulted in unexcepted aad buggy behavior

Expand All @@ -65,7 +66,13 @@ private function display_payment_slip($order, $is_for_sending) {
if ($is_for_sending) {
$image_identifier = 'payment-slip';
$img_element_alt = __('Problem loading image of payment slip', $this->domain);
echo "<img src=\"cid:$image_identifier\" alt=\"$img_element_alt\"/>";
if (!empty($this->options['payment_slip_email_width'])) {
$width_attribute = "width=\"{$this->options['payment_slip_email_width']}\"";
}
else {
$width_attribute = '';
}
echo "<img src=\"cid:$image_identifier\" alt=\"$img_element_alt\" $width_attribute/>";

add_action( 'phpmailer_init', function() use ($payment_slip_blob, $image_identifier, $file_name, $image_type) {
global $phpmailer;
Expand Down

0 comments on commit 994b8fa

Please sign in to comment.