Support

Account

Home Forums Add-ons Gallery Field How to set Gallery Field height? Reply To: How to set Gallery Field height?

  • Hi Keith and many thanks for your help which set me on the right track.
    1.- You did not say (because this is self-evident to advanced users) WHERE to put your code. I found out that it goes in one’s current WP theme functions.php file. Maybe somewhere else as well?

    2.- Your code works OK with the relevant gallery field ID.

    3.- For that code to work with all gallery fields one can change it to:

    <style type="text/css">
        .acf-gallery {
            height: 210px;
          }
        </style>

    4.- Now that—thanks to you—I understand how the Wrapper Attributes Class and ID work I thought I would refine your solution by creating a .galleryheight210 style in my functions.PHP file and would apply it in my gallery field’s Wrapper Attributes Class. Unfortunately this does not work, because the Wrapper’s style is not applied in the right DIV or rather is over-written later on.

    5.- There remains the question of my original attempt at a solution. In file advanced-custom-fields-pro\pro\fields\class-acf-field-gallery.php line 463 is this code:

    // set gallery height
    $height = acf_get_user_setting('gallery_height', 400);
    $height = max( $height, 200 ); // minimum height is 200
    $atts['style'] = "height:{$height}px";

    which seems to refer to a “user setting”. My question is: where in the ACF interface (or in one’s theme function.php) can we SET that user setting? If we cannot set it, what’s the use of getting it?