Plugin Directory

Changeset 3328430


Ignore:
Timestamp:
07/15/2025 05:53:57 PM (9 months ago)
Author:
levantoan
Message:

Add ALT to main image

Location:
devvn-image-hotspot
Files:
29 added
3 edited

Legend:

Unmodified
Added
Removed
  • devvn-image-hotspot/trunk/admin/inc/add_shortcode_devvn_ihotspot.php

    r3157769 r3328430  
    6666    <div class="wrap_svl" id="body_drag_<?php echo esc_attr($idPost);?>">
    6767        <div class="images_wrap">
    68         <img src="<?php echo esc_attr($maps_images); ?>">
     68            <?php
     69            if($maps_images):
     70                $image_info = get_image_info_from_url($maps_images);
     71                $alt = isset($image_info['alt']) ? sanitize_text_field($image_info['alt']) : '';
     72                ?>
     73                <img src="<?php echo esc_attr($maps_images); ?>" alt="<?php echo esc_attr($alt);?>">
     74            <?php endif;?>
    6975        </div> 
    7076         <?php if(is_array($data_points)):?>
  • devvn-image-hotspot/trunk/devvn-image-hotspot.php

    r3157769 r3328430  
    55Description: Image Hotspot help you add hotspot to your images.
    66Author: Le Van Toan
    7 Version: 1.2.8
     7Version: 1.2.9
    88Author URI: https://levantoan.com/
    99Text Domain: devvn-image-hotspot
     
    3030defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
    3131
    32 define('DEVVN_IHOTSPOT_VER', '1.2.8');
     32define('DEVVN_IHOTSPOT_VER', '1.2.9');
    3333define('DEVVN_IHOTSPOT_DEV_MOD', true);
    3434
     
    229229    <div class="wrap_svl view-has-value" id="body_drag">
    230230        <div class="images_wrap">
    231             <?php if($maps_images):?>
    232             <img src="<?php echo esc_attr($maps_images); ?>">
     231            <?php
     232            if($maps_images):
     233            $image_info = get_image_info_from_url($maps_images);
     234            $alt = isset($image_info['alt']) ? sanitize_text_field($image_info['alt']) : '';
     235            ?>
     236            <img src="<?php echo esc_attr($maps_images); ?>" alt="<?php echo esc_attr($alt);?>">
    233237            <?php endif;?>
    234238        </div> 
     
    674678}
    675679
     680if(!function_exists('get_image_info_from_url')){
     681    function get_image_info_from_url($image_url) {
     682        global $wpdb;
     683
     684        $upload_dir = wp_upload_dir();
     685        $relative_path = str_replace($upload_dir['baseurl'] . '/', '', $image_url);
     686
     687        $attachment_id = $wpdb->get_var( $wpdb->prepare( "
     688            SELECT post_id FROM {$wpdb->postmeta}
     689            WHERE meta_key = '_wp_attached_file'
     690            AND meta_value = %s
     691            LIMIT 1
     692        ", $relative_path ) );
     693
     694        if (!$attachment_id) return false;
     695
     696        $alt      = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
     697        $title    = get_the_title($attachment_id);
     698        $caption  = wp_get_attachment_caption($attachment_id);
     699        $desc     = get_post_field('post_content', $attachment_id);
     700
     701        return [
     702            'ID'      => $attachment_id,
     703            'alt'     => $alt,
     704            'title'   => $title,
     705            'caption' => $caption,
     706            'desc'    => $desc,
     707        ];
     708    }
     709}
  • devvn-image-hotspot/trunk/readme.txt

    r3157771 r3328430  
    44Tags: hotspot, points, image, maps, image hotspot
    55Requires at least: 4.6
    6 Tested up to: 6.6.1
    7 Stable tag: 1.2.8
     6Tested up to: 6.8.2
     7Stable tag: 1.2.9
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0
     
    5050
    5151For more information, see [Releases](https://levantoan.com/devvn-image-hotspot).
     52
     53= 1.2.9 - 16/07/2025 =
     54
     55* Add ALT to main image
    5256
    5357= 1.2.8 - 26/09/2024 =
Note: See TracChangeset for help on using the changeset viewer.