Plugin Directory

Changeset 3488485


Ignore:
Timestamp:
03/22/2026 11:19:22 PM (6 days ago)
Author:
janzeman
Message:

Release 2.0.1

Location:
janzeman-shared-albums-for-google-photos/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • janzeman-shared-albums-for-google-photos/trunk/includes/class-data-provider.php

    r3488144 r3488485  
    146146     * Extract album title from HTML
    147147     *
    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.).
    150151     *
    151152     * @param string $html HTML content
     
    153154     */
    154155    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
    156157        if ( preg_match( '/<title[^>]*>([^<]+)<\/title>/i', $html, $match ) ) {
    157158            $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 );
    161160            if ( ! empty( $title ) ) {
    162                 return $this->clean_album_title( $title );
     161                return $title;
    163162            }
    164163        }
    165164
    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
    167167        if ( preg_match( '/<\s*meta\s+property=["\']og:title["\']\s+content=["\']([^"\']+)["\']/i', $html, $match ) ) {
    168168            $title = $match[1];
     
    173173        }
    174174
    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
    187185     * @return string Cleaned title
    188186     */
    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 ) {
    190203        // Remove emoji characters (camera icons, etc.)
    191204        $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  
    55 * Author URI: https://github.com/JanZeman
    66 * 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.0
     7 * Version: 2.0.1
    88 * Requires at least: 5.0
    99 * Requires PHP: 7.0
     
    2323
    2424// Define plugin constants
    25 define( 'JZSA_VERSION', '2.0.0' );
     25define( 'JZSA_VERSION', '2.0.1' );
    2626define( 'JZSA_PLUGIN_FILE', __FILE__ );
    2727define( 'JZSA_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  • janzeman-shared-albums-for-google-photos/trunk/readme.txt

    r3488144 r3488485  
    55Tested up to: 6.9
    66Requires PHP: 7.0
    7 Stable tag: 2.0.0
     7Stable tag: 2.0.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    198198== Changelog ==
    199199
     200= 2.0.1 =
     201* Fixed album titles being truncated (dates and special characters are now preserved)
     202
    200203= 2.0.0 =
    201204* Gallery mode support
Note: See TracChangeset for help on using the changeset viewer.