👁 查看:Image.php
路径:/home/forge/kingkrunch.com/wp/wp-content/plugins/newsletter/classes/Newsletter/Composer/Image.php
大小:903 B · 修改:2026-09-30 14:36:39 · 权限:0644 · 可写
<?php
namespace Newsletter\Composer;

defined('ABSPATH') || exit;

/**
 * Used only for IDE autocompletion!
 */
class Image {
    var $id;
    var $url;
    var $width;
    var $height;
    var $alt;
    var $link;
    var $align = 'center';

    /** Sets the width keeping the aspect ratio */
    public function set_width($width) {
        $width = (int) $width;
        if (empty($width)) {
            return;
        }
        if ($this->width < $width) {
            return;
        }
        $this->height = floor(($width / $this->width) * $this->height);
        $this->width = $width;
    }

    /** Sets the height  keeping the aspect ratio */
    public function set_height($height) {
        $height = (int) $height;
        if (empty($height)) {
            return;
        }
        $this->width = floor(($height / $this->height) * $this->width);
        $this->height = $height;
    }
}