Problem/Motivation

I was trying to style the preview page to look more like the final rendering of our styles and noted that there's no easy way to differentiate when a specific preview thumbnail is being looked at.

Proposed resolution

Add the image style name in a data attribute on each thumbnail, then transfer this as a class to the larger preview image when replacing it. Also transfer the data attribute to keep track of which class to remove when previewing something else.

Remaining tasks

Review/suggestions.

User interface changes

None with the original UI.

API changes

Not sure if the template is considered part of the API, but this patch only adds a data attribute to the thumbnails.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TwoD created an issue. See original summary.

bleen’s picture

Status: Needs review » Needs work

Generally I think this is a good enhancement, but I've found an issue:

If I have three image styles defined - "square", "tall", and "wide" - and I click on the square thumbnail then the main preview images is assigned the class "square". If I then click on the "tall" thumbnail, without first clicking somewhere on the background to reset the main preview to the original image then the "square" class is not properly removed. I end up with multiple classes on that main preview image (e.g. class="square tall").

TwoD’s picture

Status: Needs work » Needs review
FileSize
2.71 KB
786 bytes

Heh, forgot about this. We only used CSS overrides for one of the styles so didn't notice it.

  • bleen committed f040d0d on 8.x-1.x authored by TwoD
    Issue #2844560 by TwoD: Set image style name as class on preview image
    
bleen’s picture

Status: Needs review » Fixed

looks great!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.