Changeset 3371152
- Timestamp:
- 10/01/2025 02:11:34 PM (6 months ago)
- Location:
- media-focus-point
- Files:
-
- 7 added
- 4 edited
-
tags/2.0.3 (added)
-
tags/2.0.3/admin.css (added)
-
tags/2.0.3/languages (added)
-
tags/2.0.3/languages/media-focus-point.pot (added)
-
tags/2.0.3/media-focus-point.php (added)
-
tags/2.0.3/readme.txt (added)
-
tags/2.0.3/script.js (added)
-
trunk/admin.css (modified) (3 diffs)
-
trunk/media-focus-point.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/script.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
media-focus-point/trunk/admin.css
r3359922 r3371152 9 9 width: 100%; 10 10 height: 100%; 11 z-index: 9999 ;11 z-index: 9999999999; 12 12 align-items: center; 13 13 justify-content: center; … … 38 38 .wpcmfp-overlay .wpcmfp-controls span{ 39 39 margin: 0 5px; 40 } 41 .wpcmfp-overlay:not(.contains-video) span.wpcmfp-toggle-video-controls { 42 display: none; 40 43 } 41 44 .wpcmfp-overlay .wpcmfp-close{ … … 75 78 position: relative; 76 79 } 80 77 81 .wpcmfp-overlay img{ 78 82 cursor: crosshair; -
media-focus-point/trunk/media-focus-point.php
r3359929 r3371152 1 1 <?php 2 2 /** 3 * Plugin Name: Media Focus Point4 * Description: Ensures that your selected focus area of an image or video remains centered and visible, even when resized.5 * Version: 2.0.2 6 * Author: WP Company7 * Author URI: https://www.wpcompany.nl8 * Text Domain: media-focus-point9 * Domain Path: /languages10 * Tested up to: 6.8.2 11 * License: GPLv3 or later12 * License URI: http://www.gnu.org/licenses/gpl-3.0.html13 */3 * Plugin Name: Media Focus Point 4 * Description: Ensures that your selected focus area of an image or video remains centered and visible, even when resized. 5 * Version: 2.0.3 6 * Author: WP Company 7 * Author URI: https://www.wpcompany.nl 8 * Text Domain: media-focus-point 9 * Domain Path: /languages 10 * Tested up to: 6.8.3 11 * License: GPLv3 or later 12 * License URI: http://www.gnu.org/licenses/gpl-3.0.html 13 */ 14 14 15 15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly … … 54 54 55 55 $html = ' 56 <input type="hidden" value="' . esc_attr( $field_value ) . '" id="wpcmfp_bg_pos_desktop_id" name="attachments[' . $post->ID . '][bg_pos_desktop]"> 57 <div class="wpcmfp-overlay wpcmfp-image_focus_point"> 58 <div class="wpcmfp-img-container"> 59 <div class="wpcmfp-header"> 60 <div class="wpcmfp-wrapp"> 61 <h3>' . __( 'Click on the media to set the focus point', 'media-focus-point' ) . '</h3> 62 <div class="wpcmfp-controls"> 63 ' . ( $is_video ? ' 64 <span class="wpcmfp-button button-secondary wpcmfp-button" onclick="toggle_controls()"> 65 ' . __( 'Toggle Controls', 'media-focus-point' ) . ' 66 </span>' : '' ) . ' 67 <span class="button button-secondary" onclick="cancel_focus()"> 68 ' . __( 'Cancel', 'media-focus-point' ) . ' 69 </span> 70 <span class="button button-primary" onclick="close_overlay()"> 71 ' . __( 'Save', 'media-focus-point' ) . ' 72 </span> 73 </div> 74 </div> 75 </div> 76 <div class="wpcmfp-container"> 77 <div class="wpcmfp-pin"></div> 78 ' . $media_tag . ' 79 </div> 80 </div> 81 </div> 56 <input 57 type="hidden" 58 value="' . esc_attr( $field_value ) . '" 59 id="wpcmfp_bg_pos_desktop_id" 60 name="attachments[' . $post->ID . '][bg_pos_desktop]" 61 data-media-tag="' . esc_attr( base64_encode($media_tag) ) . '" 62 data-is-video="' . ($is_video ? '1' : '0') . '" 63 > 82 64 <div class="wpcmfp-focusp_label_holder"> 83 65 <div id="wpcmfp_desktop_value"> … … 98 80 id="wpcmfp_label_desktop" 99 81 onclick="set_focus(0)" 100 value="' . $label . '"> 101 <input 82 value="' . $label . '" 83 > 84 <input 102 85 type="button" 103 86 class="button button-secondary button-small" 104 87 id="wpcmfp_reset_desktop" 105 88 onclick="reset_focus()" 106 value="' . __( 'Reset', 'media-focus-point' ) . '" ' . $disabled . '> 89 value="' . __( 'Reset', 'media-focus-point' ) . '" ' . $disabled . ' 90 > 107 91 </div> 108 92 '; … … 208 192 }, 10, 2); 209 193 210 211 212 213 214 194 // Enqueue admin styles/scripts 215 195 function wpcmfp_media_focus_point_admin_scripts() { … … 281 261 } 282 262 } 263 264 add_action( 'admin_footer', function() { 265 ?> 266 <div class="wpcmfp-overlay wpcmfp-image_focus_point"> 267 <div class="wpcmfp-img-container"> 268 <div class="wpcmfp-header"> 269 <div class="wpcmfp-wrapp"> 270 <h3><?= __( 'Click on the media to set the focus point', 'media-focus-point' ) ?></h3> 271 <div class="wpcmfp-controls"> 272 <span class="wpcmfp-button button-secondary wpcmfp-button wpcmfp-toggle-video-controls" onclick="toggle_controls()"> 273 <?= __( 'Toggle Controls', 'media-focus-point' ) ?> 274 </span> 275 <span class="button button-secondary" onclick="cancel_focus()"> 276 <?= __( 'Cancel', 'media-focus-point' ) ?> 277 </span> 278 <span class="button button-primary" onclick="close_overlay()"> 279 <?= __( 'Save', 'media-focus-point' ) ?> 280 </span> 281 </div> 282 </div> 283 </div> 284 <div class="wpcmfp-container"> 285 <div class="wpcmfp-pin"></div> 286 </div> 287 </div> 288 </div> 289 <?php 290 } ); -
media-focus-point/trunk/readme.txt
r3359922 r3371152 3 3 Tags: focus, focal, image, background, video 4 4 Requires at least: 6.0 5 Tested up to: 6.8. 25 Tested up to: 6.8.3 6 6 Requires PHP: 7.4 7 Stable tag: 2.0. 27 Stable tag: 2.0.3 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 110 110 == Changelog == 111 111 112 = 2.0.3 = 113 * Fixed an issue with overlapping elements when opening the focus point overlay within a media library opened in a block editor. 114 112 115 = 2.0.2 = 113 116 * Fixed aspect ratio of wide images while selecting a focus point -
media-focus-point/trunk/script.js
r3359922 r3371152 143 143 144 144 async function set_focus(e) { 145 const hiddenInput = document.getElementById('wpcmfp_bg_pos_desktop_id'); 146 const mediaContainer = document.querySelector('.wpcmfp-container'); 147 const overlay = document.querySelector('.wpcmfp-overlay'); 148 const mediaPreviewContainer = document.createElement('div'); 149 // If the overlay doesn't contain the contains-video class, it will hide the controls toggle button 150 if (hiddenInput.dataset.isVideo === '1') { 151 overlay.classList.add('contains-video'); 152 } else { 153 overlay.classList.remove('contains-video'); 154 } 155 mediaPreviewContainer.classList.add('wpcmfp-media-preview-container'); 156 // Fetch data-attribute data-media-tag, which should contain a base64 encoded string of the media tag 157 mediaPreviewContainer.innerHTML = atob(hiddenInput.dataset.mediaTag); 158 // Save pin to add back again later 159 const pin = mediaContainer.querySelector('.wpcmfp-pin'); 160 // Clear overlay contents 161 mediaContainer.innerHTML = ''; 162 // Re-add the pin 163 if (pin) mediaContainer.append(pin); 164 // Add image to overlay 165 mediaContainer.append(mediaPreviewContainer); 166 145 167 replaceCustomVideoElements() 146 168 document.querySelectorAll(".wpcmfp-media-frame-content,.wpcmfp-media-sidebar").forEach(el => el.classList.add('show'));
Note: See TracChangeset
for help on using the changeset viewer.