Making WordPress.org

Changeset 13975


Ignore:
Timestamp:
08/19/2024 08:12:52 PM (7 weeks ago)
Author:
coffee2code
Message:

Photo Directory, Admin: Show a toggle-able list of all EXIF data from a photo.

Props roytanck, jeroenrotty, coffee2code.
Fixes #7734.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/assets/css/admin.css

    r13255 r13975  
    133133    margin-left: 1rem;
    134134}
     135
     136.photo-all-exif-container {
     137    border-top: 1px solid #ccc;
     138    margin-top: 6px;
     139    padding-top: 6px;
     140}
     141.photo-all-exif {
     142    overflow-wrap: anywhere;
     143}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/assets/js/admin.js

    r13209 r13975  
    9292        document.querySelector('label[for="photoskip-hide"]')?.remove();
    9393    }
     94
     95    // Handle toggle for full listing of EXIF data.
     96    const exifContainer = document.querySelector('.photo-all-exif');
     97    const exifToggle = document.querySelector('#photo-all-exif-toggle');
     98    if (exifContainer && exifToggle) {
     99        function toggleAllEXIF(event) {
     100            const newExpandState = exifContainer.classList.toggle('hidden');
     101            exifToggle.setAttribute('aria-expanded', newExpandState ? 'false' : 'true');
     102            event.preventDefault();
     103        }
     104        // Hide the full EXIF data by default.
     105        exifContainer.classList.add('hidden');
     106        exifToggle.setAttribute('aria-expanded', 'false');
     107        // Clicking the toggle should toggle the visibility of the EXIF data.
     108        exifToggle.addEventListener('click', toggleAllEXIF, true);
     109    }
     110
    94111}, false);
    95112
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/admin.php

    r13814 r13975  
    593593        }
    594594        echo "</dl>\n";
     595
     596        // Show ALL EXIF data.
     597        $all_exif = Photo::get_all_exif( $parent_id );
     598        if ( $all_exif ) {
     599            ksort( $all_exif );
     600
     601            echo '<div class="photo-all-exif-container">';
     602            echo '<button id="photo-all-exif-toggle" class="button-link hide-if-no-js" type="button" aria-expanded="true">' . esc_html__( 'Toggle all raw EXIF data', 'wporg-photos' ) . '</button>';
     603            echo '<dl class="photo-all-exif">';
     604
     605            foreach ( $all_exif as $key => $value ) {
     606                if ( '' === $value ) {
     607                    continue;
     608                }
     609
     610                echo '<dt>' . esc_html( $key ) . "</dt>\n";
     611                if ( is_array( $value ) ) {
     612                    $value = '[' . implode( ', ', $value ) . ']';
     613                }
     614                echo '<dd>' . esc_html( $value ) . "</dd>\n";
     615            }
     616
     617            echo "</dl></div>\n";
     618        }
    595619    }
    596620
Note: See TracChangeset for help on using the changeset viewer.