Changeset 3488485
- Timestamp:
- 03/22/2026 11:19:22 PM (6 days ago)
- Location:
- janzeman-shared-albums-for-google-photos/trunk
- Files:
-
- 3 edited
-
includes/class-data-provider.php (modified) (3 diffs)
-
janzeman-shared-albums-for-google-photos.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
janzeman-shared-albums-for-google-photos/trunk/includes/class-data-provider.php
r3488144 r3488485 146 146 * Extract album title from HTML 147 147 * 148 * Google Photos HTML contains the album title in the <title> tag, which is more reliable 149 * than OG tags which may contain photo-specific dates. 148 * Two sources are tried in order: 149 * - Primary: <title> tag — contains the user's album name with a "- Google Photos" suffix. 150 * - Secondary: og:title meta tag — contains Google-appended noise (dates, camera icons, etc.). 150 151 * 151 152 * @param string $html HTML content … … 153 154 */ 154 155 private function extract_album_title( $html ) { 155 // Try to extract from <title> tag first (more reliable for album name)156 // Primary source: <title> tag — contains only the user's album name 156 157 if ( preg_match( '/<title[^>]*>([^<]+)<\/title>/i', $html, $match ) ) { 157 158 $title = html_entity_decode( $match[1], ENT_QUOTES | ENT_HTML5, 'UTF-8' ); 158 // <title> often has format: "Album Name - Google Photos" 159 $title = preg_replace( '/\s*-\s*Google Photos\s*$/i', '', $title ); 160 $title = trim( $title ); 159 $title = $this->clean_primary_album_title( $title ); 161 160 if ( ! empty( $title ) ) { 162 return $t his->clean_album_title( $title );161 return $title; 163 162 } 164 163 } 165 164 166 // Fallback to og:title meta tag 165 // Secondary source: og:title meta tag — contains Google-appended noise 166 // (dates, camera icons, separators) so we clean it up aggressively 167 167 if ( preg_match( '/<\s*meta\s+property=["\']og:title["\']\s+content=["\']([^"\']+)["\']/i', $html, $match ) ) { 168 168 $title = $match[1]; … … 173 173 } 174 174 175 // Clean the title: remove dates, camera info, icons 176 return $this->clean_album_title( $title ); 177 } 178 179 /** 180 * Clean album title by removing dates, camera icons, and metadata 181 * 182 * Google Photos OG:title often contains photo-specific metadata like: 183 * "Saturday, Jan 29, 2005" or "Album Name - Jan 29, 2005" 184 * We need to extract just the album name portion. 185 * 186 * @param string $title Raw title from Open Graph tag 175 return $this->clean_secondary_album_title( $title ); 176 } 177 178 /** 179 * Clean the primary album title (from <title> tag) 180 * 181 * Only removes the "- Google Photos" suffix that Google appends. 182 * The rest of the title is the user's original album name and is preserved as-is. 183 * 184 * @param string $title Raw title from <title> tag 187 185 * @return string Cleaned title 188 186 */ 189 private function clean_album_title( $title ) { 187 private function clean_primary_album_title( $title ) { 188 $title = preg_replace( '/\s*-\s*Google Photos\s*$/i', '', $title ); 189 return trim( $title ); 190 } 191 192 /** 193 * Clean the secondary album title (from og:title meta tag) 194 * 195 * Google's og:title contains noise appended to the album name: 196 * dates ("· Sunday, Mar 22"), camera icons (📸), camera models, etc. 197 * We strip these aggressively since the user's original title is buried in there. 198 * 199 * @param string $title Raw title from og:title meta tag 200 * @return string Cleaned title 201 */ 202 private function clean_secondary_album_title( $title ) { 190 203 // Remove emoji characters (camera icons, etc.) 191 204 $title = preg_replace( '/[\x{1F300}-\x{1F9FF}]/u', '', $title ); -
janzeman-shared-albums-for-google-photos/trunk/janzeman-shared-albums-for-google-photos.php
r3488144 r3488485 5 5 * Author URI: https://github.com/JanZeman 6 6 * Description: Display publicly shared Google Photos albums with a modern Swiper-based gallery viewer. Not affiliated with or endorsed by Google LLC. 7 * Version: 2.0. 07 * Version: 2.0.1 8 8 * Requires at least: 5.0 9 9 * Requires PHP: 7.0 … … 23 23 24 24 // Define plugin constants 25 define( 'JZSA_VERSION', '2.0. 0' );25 define( 'JZSA_VERSION', '2.0.1' ); 26 26 define( 'JZSA_PLUGIN_FILE', __FILE__ ); 27 27 define( 'JZSA_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); -
janzeman-shared-albums-for-google-photos/trunk/readme.txt
r3488144 r3488485 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.0 7 Stable tag: 2.0. 07 Stable tag: 2.0.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 198 198 == Changelog == 199 199 200 = 2.0.1 = 201 * Fixed album titles being truncated (dates and special characters are now preserved) 202 200 203 = 2.0.0 = 201 204 * Gallery mode support
Note: See TracChangeset
for help on using the changeset viewer.