Changeset 3236642
- Timestamp:
- 02/07/2025 02:11:58 PM (14 months ago)
- Location:
- media-focus-point
- Files:
-
- 7 added
- 2 edited
-
tags/1.3 (added)
-
tags/1.3/admin.css (added)
-
tags/1.3/languages (added)
-
tags/1.3/languages/media-focus-point.pot (added)
-
tags/1.3/media-focus-point.php (added)
-
tags/1.3/readme.txt (added)
-
tags/1.3/script.js (added)
-
trunk/media-focus-point.php (modified) (1 diff)
-
trunk/readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
media-focus-point/trunk/media-focus-point.php
r3216407 r3236642 106 106 107 107 add_action( 'admin_enqueue_scripts', 'wpcmfp_media_focus_point_admin_scripts' ); 108 109 108 109 //Add the background-position to the style of an element 110 function MFP_Background( $attachment_id, $include_image = true ) { 111 // Get the stored background position 112 $bg_pos_desktop = get_post_meta( $attachment_id, 'bg_pos_desktop', true ); 113 114 // Default background position if not set 115 if ( empty( $bg_pos_desktop ) ) { 116 $bg_pos_desktop = '50% 50%'; 117 } 118 119 // Start building the style 120 $style = 'background-position: ' . esc_attr( $bg_pos_desktop ) . ';'; 121 122 // Include background-image if enabled 123 if ( $include_image ) { 124 $image_url = wp_get_attachment_url( $attachment_id ); 125 if ( $image_url ) { 126 $style = 'background-image: url(' . esc_url( $image_url ) . '); ' . $style . ' background-size: cover;'; 127 } 128 } 129 130 return $style; 131 } -
media-focus-point/trunk/readme.txt
r3216446 r3236642 5 5 Tested up to: 6.7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1.2. 27 Stable tag: 1.2.1 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 21 21 == Installation == 22 22 23 If you installed the plugin and set a focus point on the image **it should work right away**. 24 Most WordPress themes already use this standard WordPress method to render featured images. 25 23 26 To display an image in your custom template with the focus point applied, you can use the following code snippet: 24 Most WordPress themes already use this standard WordPress method to render featured images.25 27 26 28 **For featured images (post thumbnails):** … … 29 31 echo get_the_post_thumbnail('', 'full'); 30 32 ?> 33 34 **For background images:** 35 36 <div class="myelement" style="<?= MFP_Background($image_id, false); ?>"></div> 31 37 32 38 … … 79 85 == Changelog == 80 86 87 = 1.3 = 88 * New function MFP_Background to dynamically generate background position for background images. 89 81 90 = 1.2.2 = 82 91 * Remove the disabled script that caused errors in certain situations
Note: See TracChangeset
for help on using the changeset viewer.