Skip to content

Named sizes for 'preview_size' break preview images before page reload #844

Description

@Cai333

Expected Behavior:

Images added to a file or file_list field should show a preview at the correct size (specified with preview_size).

Actual Behavior:

Regardless of the preview_size set, the preview image (that is initially added to the page via JS) is actually the full size image (the image shown after reloading the page is correct, the issue is only with the JS added image from the media window).

If preview_size is set as an array of height/width values then the full size image is resized to the correct size (resulting in squashed images):

screenshot 2017-01-22 20 25 33

If preview_size is set to a named size (e.g. thumbnail) then the added full size image is resized to a default of 50 x 50 px (for a file_list field) or 350 x 350 px (for a file field):

screenshot 2017-01-22 20 30 39

The offending code is in CMB2_Type_File_List.php line 28 and CMB2_Type_File.php line 31:

'data-previewsize' => is_array( $img_size ) ? '[' . implode( ',', $img_size ) . ']' : 350,

The numbers are hardcoded again in cmb2.js lines 223–224 and 265, but they shouldn't be an issue if the correct sizes are passed from the field.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo