‘ . $html);
// $images = $dom->getElementsByTagName(‘img’);
// foreach ($images as $img) {
// $src = $img->getAttribute(‘src’);
// if (!$src) continue;
// /* —————- ALT FIX —————- */
// if (!$img->hasAttribute(‘alt’) || trim($img->getAttribute(‘alt’)) == ”) {
// $filename = basename(parse_url($src, PHP_URL_PATH));
// $alt = pathinfo($filename, PATHINFO_FILENAME);
// $alt = str_replace([‘-‘, ‘_’], ‘ ‘, $alt);
// $alt = ucwords($alt);
// $img->setAttribute(‘alt’, $alt);
// }
// /* —————- SIZE FIX —————- */
// if (!$img->hasAttribute(‘width’) || !$img->hasAttribute(‘height’)) {
// $image_path = ABSPATH . str_replace(home_url(‘/’), ”, $src);
// if (file_exists($image_path)) {
// $size = getimagesize($image_path);
// if ($size) {
// $img->setAttribute(‘width’, $size[0]);
// $img->setAttribute(‘height’, $size[1]);
// }
// }
// }
// /* —————- PERFORMANCE FIX —————- */
// if (!$img->hasAttribute(‘loading’)) {
// $img->setAttribute(‘loading’, ‘lazy’);
// }
// if (!$img->hasAttribute(‘decoding’)) {
// $img->setAttribute(‘decoding’, ‘async’);
// }
// }
// return $dom->saveHTML();
// });
// });
// add_action(‘template_redirect’, function () {
// if (is_admin()) return;
// ob_start(function ($html) {
// // ❌ Skip if single post and category = press-release
// if (is_single() && has_category(‘press-release’)) {
// return $html;
// }
// libxml_use_internal_errors(true);
// $dom = new DOMDocument();
// $dom->loadHTML(‘‘ . $html);
// $links = $dom->getElementsByTagName(‘a’);
// $site_host = parse_url(home_url(), PHP_URL_HOST);
// foreach ($links as $link) {
// $href = $link->getAttribute(‘href’);
// if (!$href) continue;
// $link_host = parse_url($href, PHP_URL_HOST);
// // External link check
// if ($link_host && $link_host !== $site_host) {
// $link->setAttribute(‘rel’, ‘noopener nofollow noreferrer’);
// $link->setAttribute(‘target’, ‘_blank’);
// }
// }
// return $dom->saveHTML();
// });
// });
Source: https://bitcoinworld.co.in/eur-usd-forecast-resistance-100-sma/

