Making WordPress.org


Ignore:
Timestamp:
03/28/2022 11:29:52 PM (5 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.