[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.128.168.219: ~ $
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing

namespace MailPoet\Newsletter\Renderer\Blocks;

if (!defined('ABSPATH')) exit;


use MailPoet\Newsletter\Renderer\EscapeHelper as EHelper;
use MailPoet\Newsletter\Renderer\StylesHelper;
use MailPoet\WP\Functions as WPFunctions;

class Image {
  public function render($element, $columnBaseWidth) {
    if (empty($element['src'])) {
      return '';
    }
    if (substr($element['src'], 0, 1) == '/' && substr($element['src'], 1, 1) != '/') {
      $element['src'] = WPFunctions::get()->getOption('siteurl') . $element['src'];
    }

    $element['width'] = str_replace('px', '', $element['width']);
    $element['height'] = str_replace('px', '', $element['height']);
    $originalWidth = 0;
    if (is_numeric($element['width']) && is_numeric($element['height'])) {
      $element['width'] = (int)$element['width'];
      $element['height'] = (int)$element['height'];
      $originalWidth = $element['width'];
      $element = $this->adjustImageDimensions($element, $columnBaseWidth);
    }

    // If image was downsized because of column width set width to aways fill full column (e.g. on mobile)
    $style = '';
    if ($element['fullWidth'] === true && $originalWidth > $element['width']) {
      $style = 'style="width:100%"';
    }

    $imageTemplate = '
      <img src="' . EHelper::escapeHtmlLinkAttr($element['src']) . '" width="' . EHelper::escapeHtmlAttr($element['width']) . '" alt="' . EHelper::escapeHtmlAttr($element['alt']) . '"' . $style . '/>
      ';
    if (!empty($element['link'])) {
      $imageTemplate = '<a href="' . EHelper::escapeHtmlLinkAttr($element['link']) . '">' . trim($imageTemplate) . '</a>';
    }
    $align = 'center';
    if (!empty($element['styles']['block']['textAlign']) && in_array($element['styles']['block']['textAlign'], ['left', 'right'])) {
      $align = $element['styles']['block']['textAlign'];
    }

    $template = '
      <tr>
        <td class="mailpoet_image ' . (($element['fullWidth'] === false) ? 'mailpoet_padded_vertical mailpoet_padded_side' : '') . '" align="' . EHelper::escapeHtmlAttr($align) . '" valign="top">
          ' . trim($imageTemplate) . '
        </td>
      </tr>';
    return $template;
  }

  public function adjustImageDimensions($element, $columnBaseWidth) {
    $paddedWidth = StylesHelper::$paddingWidth * 2;
    // scale image to fit column width
    if ($element['width'] > $columnBaseWidth) {
      $ratio = $element['width'] / $columnBaseWidth;
      $element['width'] = $columnBaseWidth;
      $element['height'] = (int)ceil($element['height'] / $ratio);
    }
    // resize image if the image is padded and wider than padded column width
    if (
      $element['fullWidth'] === false &&
      $element['width'] > ($columnBaseWidth - $paddedWidth)
    ) {
      $ratio = $element['width'] / ($columnBaseWidth - $paddedWidth);
      $element['width'] = $columnBaseWidth - $paddedWidth;
      $element['height'] = (int)ceil($element['height'] / $ratio);
    }
    return $element;
  }
}

Filemanager

Name Type Size Permission Actions
AbandonedCartContent.php File 2.55 KB 0644
AutomatedLatestContentBlock.php File 2.39 KB 0644
Button.php File 4.89 KB 0644
Coupon.php File 4.13 KB 0644
Divider.php File 1.68 KB 0644
Footer.php File 2.29 KB 0644
Header.php File 2.29 KB 0644
Image.php File 3.01 KB 0644
Placeholder.php File 676 B 0644
Renderer.php File 4.26 KB 0644
Social.php File 1.46 KB 0644
Spacer.php File 701 B 0644
Text.php File 6.79 KB 0644
index.php File 6 B 0644