Making WordPress.org

Changeset 11715


Ignore:
Timestamp:
03/28/2022 11:29:52 PM (3 years ago)
Author:
coffee2code
Message:

Photo Directory, Admin: Blur potentially controversial photos in the admin.

Such images should be obscured to prevent repeated, unexpected, and undesired exposure.

  • Blurs affected photos in post listings.
  • Blurs affected photos when editing photo post.
  • When editing blurred photo, clicking photo will initially unblur photo. Click again to follow link.
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

    r11689 r11715  
    4040    max-height: initial;
    4141}
     42
     43.photos-photo-link {
     44    display: inline-block;
     45    overflow: hidden;
     46}
     47.photos-photo-link img.blurred {
     48    filter: blur(4rem);
     49}
     50.column-wporg-photo .photos-photo-link img.blurred {
     51    filter: blur( 0.7rem );
     52}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/assets/js/admin.js

    r11712 r11715  
    22    // Convert Orientations taxonomy checkboxes to radio buttons.
    33    document.querySelectorAll('#photo_orientationchecklist input[type="checkbox"]').forEach((item) => {item.setAttribute('type', 'radio');});
     4
     5    // Unblur blurred photo on photo edit page when clicked.
     6    function unblurPhoto(event) {
     7        event.target.classList.remove('blurred');
     8        event.target.removeEventListener('click', unblurPhoto, true);
     9        event.preventDefault();
     10    }
     11    document.querySelector('#photos_photo .photos-photo-link img.blurred').addEventListener('click', unblurPhoto, true);
     12
    413}, false);
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/admin.php

    r11714 r11715  
    191191
    192192        $image_id = get_post_thumbnail_id( $post );
    193         $image = wp_get_attachment_image( $image_id );
     193        $classes = '';
     194        if ( Photo::is_controversial( $post ) ) {
     195            $classes .= ' blurred';
     196        }
     197        $image = wp_get_attachment_image( $image_id, 'thumbnail', false, [ 'class' => trim( $classes ) ] );
    194198
    195199        $can_edit_post = current_user_can( 'edit_post', $post->ID );
     
    199203                $prefixed_format,
    200204                sprintf(
    201                     '<div><a class="row-title" href="%s" aria-label="%s">%s</a></div>',
     205                    '<div><a class="photos-photo-link row-title" href="%s" aria-label="%s">%s</a></div>',
    202206                    get_edit_post_link( $post_id ),
    203207                    /* translators: %s: Post title. */
     
    487491        $thumb_url = wp_get_attachment_image_src( $image_id, [ 900, 450 ], true );
    488492
     493        $classes = 'photo-thumbnail';
     494
     495        if ( Photo::is_controversial( $image_id ) ) {
     496            $classes .= ' blurred';
     497        }
     498
    489499        printf(
    490             '<a class="row-title" href="%s" target="_blank" aria-label="%s"><img class="photo-thumbnail" src="%s" style="max-width:100%%" alt="" /></a>',
     500            '<a class="photos-photo-link row-title" href="%s" target="_blank" aria-label="%s"><img class="%s" src="%s" style="max-width:100%%" alt="" /></a>',
    491501            wp_get_attachment_url( $image_id ),
    492502            /* translators: %s: Post title. */
    493503            esc_attr( sprintf( __( 'Edit photo associated with post &#8220;%s&#8221;', 'wporg-photos' ), $post->post_title ) ),
     504            esc_attr( $classes ),
    494505            set_url_scheme( $thumb_url[0] )
    495506        );
Note: See TracChangeset for help on using the changeset viewer.