From eee9db2d4ccb4fc0a92fb54cc8b7219374f5e25f Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:04:11 +0200 Subject: [PATCH 1/2] composer require pronamic/wp-pay-logos --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index ac9ddc8..38842fc 100644 --- a/composer.json +++ b/composer.json @@ -69,6 +69,7 @@ "pronamic/wp-gravityforms-nl": "^3.0", "pronamic/wp-money": "^2.4", "pronamic/wp-number": "^1.3", + "pronamic/wp-pay-logos": "^2.2", "woocommerce/action-scheduler": "^3.7", "wp-pay-gateways/mollie": "^4.10", "wp-pay/core": "dev-main as 4.18" From 9f304339e8d589498c30f63ad5930c9a75361c07 Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:20:57 +0200 Subject: [PATCH 2/2] Update IssuersField.php --- src/IssuersField.php | 50 +++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/src/IssuersField.php b/src/IssuersField.php index a5a7097..e5980c8 100644 --- a/src/IssuersField.php +++ b/src/IssuersField.php @@ -15,6 +15,7 @@ use Pronamic\WordPress\Pay\Fields\IDealIssuerSelectField; use Pronamic\WordPress\Pay\Core\PaymentMethods; use Pronamic\WordPress\Pay\Plugin; +use Pronamic\WpPayLogos\ImageService; /** * Title: WordPress pay extension Gravity Forms issuers field @@ -294,19 +295,25 @@ public function get_field_input( $form, $value = '', $entry = null ) { // Icon file and size. switch ( $this->pronamicPayDisplayMode ) { case 'icons-24': - $dimensions = [ 24, 24 ]; + $display_width = 24; + $display_height = 24; + $image_variation = 'icon-512x512.svg'; break; case 'icons-64': - $dimensions = [ 64, 64 ]; + $display_width = 64; + $display_height = 64; + $image_variation = 'icon-512x512.svg'; break; case 'icons-125': default: - $dimensions = [ 125, 60 ]; + $display_width = 125; + $display_height = 70; + $image_variation = '640x360.svg'; } - $images_path = plugin_dir_path( Plugin::$file ) . 'images/'; + $image_service = new ImageService(); // Loop issuers. foreach ( $this->choices as $choice ) { @@ -322,29 +329,21 @@ public function get_field_input( $form, $value = '', $entry = null ) { $issuer = 'test'; } - if ( ! is_dir( $images_path . $issuer ) && is_dir( $images_path . $issuer . '-bank' ) ) { - $issuer .= '-bank'; - } - - $icon_path = sprintf( - '%s/icon-%s.png', - $issuer, - implode( 'x', $dimensions ) - ); - // Radio input. $label_content = sprintf( '%s', esc_html( $choice['text'] ) ); - if ( file_exists( plugin_dir_path( Plugin::$file ) . 'images/' . $icon_path ) ) { - $icon_url = plugins_url( 'images/' . $icon_path, Plugin::$file ); + $image_path = $image_service->get_path( "ideal-issuers/$issuer/ideal-issuer-$issuer-$image_variation" ); - $label_content = sprintf( - '%1$s%1$s', - esc_html( $choice['text'] ), - esc_url( $icon_url ), - esc_url( str_replace( '.png', '@2x.png', $icon_url ) ), - esc_url( str_replace( '.png', '@3x.png', $icon_url ) ), - esc_url( str_replace( '.png', '@4x.png', $icon_url ) ) + if ( file_exists( $image_path ) ) { + $image_url = \plugins_url( \basename( $image_path ), $image_path ); + + $label_content = \sprintf( + '%s%s', + \esc_url( $image_url ), + \esc_attr( $choice['text'] ), + \esc_attr( $display_width ), + \esc_attr( $display_height ), + \esc_html( $choice['text'] ) ); } @@ -373,9 +372,6 @@ public function get_field_input( $form, $value = '', $entry = null ) { .gform_wrapper .gfield_radio li img { display: block; - - width: px; - height: px; } .gform_wrapper .gfield_radio li label { @@ -499,8 +495,6 @@ public function get_field_input( $form, $value = '', $entry = null ) { .gform_wrapper .gfield_radio li label { display: block; - height: 68px; - padding: 3px; border: 1px solid #bbb;