// ============================================
// IMAGE SEO CLASS (FIXED)
// ============================================
if (!class_exists('TimesBull_Image_SEO')) {
class TimesBull_Image_SEO {
private static $instance = null;
private $image_count = 0;
private $featured_image_id = null;
public static function get_instance() {
if (null === self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
private function __construct() {
add_filter('wp_get_attachment_image_attributes', [$this, 'add_image_attributes'], 10, 3);
add_filter('the_content', [$this, 'auto_add_image_alt']);
add_action('add_attachment', [$this, 'auto_image_seo']);
add_action('wp', [$this, 'set_featured_image_id']);
}
public function set_featured_image_id() {
if (is_singular()) {
$this->featured_image_id = get_post_thumbnail_id();
}
}
public function add_image_attributes($attr, $attachment, $size) {
$this->image_count++;
// CRITICAL FIX: Check if this is the featured image
$is_featured = ($attachment->ID === $this->featured_image_id);
if ($is_featured) {
// Featured image - ALWAYS eager, ALWAYS high priority
$attr['loading'] = 'eager';
$attr['fetchpriority'] = 'high';
$attr['decoding'] = 'async';
} elseif ($this->image_count === 1 && !is_admin()) {
// First non-featured image (e.g., logo)
$attr['loading'] = 'eager';
$attr['fetchpriority'] = 'high';
$attr['decoding'] = 'async';
} else {
// All other images - lazy load for performance
$attr['loading'] = 'lazy';
$attr['decoding'] = 'async';
// Remove fetchpriority from lazy images (prevents conflict)
if (isset($attr['fetchpriority'])) {
unset($attr['fetchpriority']);
}
}
// Ensure alt text is never empty
if (empty($attr['alt'])) {
$alt_text = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
$attr['alt'] = $alt_text ?: get_the_title($attachment->ID);
}
return $attr;
}
public function auto_add_image_alt($content) {
if (empty($content) || !is_singular() || is_admin()) {
return $content;
}
$post_title = esc_attr(get_the_title());
return preg_replace_callback('/
]+)>/i', function($matches) use ($post_title) {
$img_tag = $matches[0];
$attributes = $matches[1];
if (!preg_match('/alt=([\'"])(.*?)\1/i', $attributes, $alt_matches) || empty(trim($alt_matches[2]))) {
if (stripos($attributes, 'alt=') !== false) {
return preg_replace('/alt=([\'"])(.*?)\1/i', 'alt="' . $post_title . '"', $img_tag);
} else {
return str_replace('
$attachment_id,
'post_title' => $clean_title,
'post_excerpt' => $clean_title,
]);
update_post_meta($attachment_id, '_wp_attachment_image_alt', $clean_title);
}
}
TimesBull_Image_SEO::get_instance();
}
Redmi Note 13 Pro 5G: Redmi, a subsidiary of Xiaomi, is currently selling its popular phone at a much lower cost. The price of the company’s powerful Redmi Note 13 Pro 5G has been reduced. This phone is being offered at a significant discount by the company. The Redmi Note 13 Pro 5G has a maximum retail price (MRP) of ₹28,999, yet it is now available for less than ₹17,000. This is a great chance to buy the phone because it has never been this affordable. Here are the specifics of the offer.
The price of the Redmi Note 13 Pro 5G is at its lowest point ever. The price has been lowered by over ₹12,000 by Xiaomi. While it is now listed at ₹16,800, the phone’s MRP is ₹28,999 on the company’s official retail page. This indicates that everyone is qualified for a straight discount of ₹12,100 over the phone.
Redmi Note 13 Pro 5G’s Outstanding Features
There are some really amazing features on the Redmi Note 13 Pro 5G. It has a 6.67-inch AMOLED screen with a refresh rate of 120 Hz and a resolution of 1.5K. Dolby Vision is also supported. Its 200MP Ultra-High Resolution camera with a Samsung ISOCELL HP3 sensor is the main feature. There are three cameras on the phone. An 8-megapixel ultrawide camera serves as the secondary lens, and a 2-megapixel macro sensor serves as the third lens. At 30 frames per second, the phone can record 4K video. The phone sports a 16-megapixel camera for taking selfies.
The Snapdragon 7s Gen 2 chipset powers the phone. It has up to 256GB of storage and up to 12GB of RAM. It has a sizable 5100mAh battery that supports 67W fast charging. The phone has both AI face unlock and in-display fingerprint security. It is rated IP54 for security to water and dust.