public function twentytwenty_shortcode($atts, $content = null) { wp_enqueue_script('jquery'); wp_enqueue_script('twentytwenty-jquery-event-move'); wp_enqueue_script('twentytwenty-twentytwenty'); wp_enqueue_script('twentytwenty-plugin-script'); wp_enqueue_style('twentytwenty-twentytwenty'); require_once plugin_dir_path(__FILE__) . 'includes/smart-dom-document.php'; $doc = new SmartDOMDocument(); $doc->LoadHTML($content); $images = $doc->getElementsByTagName('img'); $images_code = ''; $width = ''; $height = ''; foreach ($images as $image) { if ($width == '') { $width = $image->getAttribute("width"); } if ($height == '') { $height = $image->getAttribute("height"); } $images_code = $images_code . '<img src="' . $image->getAttribute("src") . '"/>'; } if ($width != '') { $width = $width . 'px'; } if ($height != '') { $height = $height . 'px'; } return '<div class="twentytwenty" class="twentytwenty-container" style="display: none; max-width: 100%; width: ' . $width . '; height: ' . $height . '">' . $images_code . '</div>'; }