• Resolved Jonas Lundman

    (@jonas-lundman)


    Hi, thanks again for your work with this plugin.

    For the first time I actually use the mla gallery shortcode, after many years!(?) However,

    I noticed that the post_gallery default wp function is filtered and replaced by MLA. All my installs with wp default gallery css and styles get broken couse the MLA adds some extra “finess”, calculating gutter of columns and so on.

    Gutter can be fixed with advanced CSS, instead of forced PHP output.

    It also breaks responsive layout in many point of views, forcing MLA added margin gutter value. Impossible to style consistantly.

    The original outputs width of parent in exact % and why not keep it that way. Here is part I talking about

    $columns = intval($columns);
    $procent = (floor(1000/$columns)) / 10; // ex 16,6666 = 16.6 %
    $itemwidth = $columns > 0 ? $procent : 100;

    (slightly modded, but exactly as default function. (width 16.666 floors to 16% in originbal function, and gives 2% less gap on wide screens with 5 images….) Modern browsers handle decimal widths.)

    My point is, the beauty of MLA Gallery Options with custom paste template, is to paste old or already well styled gallerys from the past. The “new” margin added calculation of itemwith breaks this.

    Ive hacked the core files everytime on update to fix this, but would see an option to workaround or a better way to get the returned itemwith exact as expected from default wordpress post_gallery function.

    Any ideas?

    https://www.ads-software.com/extend/plugins/media-library-assistant/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for taking the time to post this message and for the investigation you’ve already done. I am trying to understand all of the details you have provided, but I have some questions.

    First, I am not sure what you mean when you say “the post_gallery default wp function is filtered and replaced by MLA”. MLA provides the [mla_gallery] shortcode, which is an alternative to the WordPress ‘[gallery]‘ shortcode. The [mla_gallery] is a completely separate shortcode, and MLA does not filter or replace or interact with the WordPress post_gallery filter or the [gallery] shortcode. I take the rest of your comments as applying to the [mla_gallery] shortcode.

    By default, [mla_gallery] does add some in-line styles that are different from the original WordPress styles. You can replace these styles with you own by creating a custom template, or you can suppress the styles entirely by coding mla_style=none. It sounds like you have figured all of that out already. You can also supply an explicit itemwidth by coding the mla_itemwidth parameter.

    Having said all that, I will confess that I have never been very happy with the default styling. I’m a plumber, not a painter, and CSS has been a challenge for me. I welcome any suggestions for improvement; I have wanted to revisit this subject for some time.

    Your code sample looks like a modification of the gallery_shortcode function in media.php – is that right? Are you hacking WordPress or MLA?

    I am happy to consider ideas for improvement, and I don’t want to force you to hack code on every update. Could you send me your code modifications (you have my e-mail) and any other details you think useful?

    Thanks again for your interest and the time you put into thinking through and raising these issues.

    Thread Starter Jonas Lundman

    (@jonas-lundman)

    Hi, a little better context provided here:

    This is my filter hook:
    add_filter('post_gallery', 'ua_post_gallery', 10, 2);

    Its an exact copy of media.php default post_gallery function, exept adding decimal to the item_width value. (16.666666 becomes 16 in default wp function, in my 16.5)

    Wrong word by me when saying mla replaces the shortcode, I mean, clones the post_gallery function, more or less…

    In many themes, we filter the ‘post_gallery’ for the mark-up matter, ONLY, and many people do so.

    MLA provides the template options in the backend and we don longer need to filter the post_gallery if we using MLA shortcode. We just clone our mark up and paste it in MLA Gallery settings. Great!

    However, the presentation (layout) is still dependend on the wp default variables that post_gallery provides. If you CHANGE hardcoded tags or values, diffrent from the core function, the presentation breaks.

    The part of original post_gallery, must be intact:

    media.php line 747

    $columns = intval($columns);
     $itemwidth = $columns > 0 ? floor(100/$columns) : 100;

    Your function: class-mla-shortcodes.php

    $itemwidth = $arguments['columns'] > 0 ? (floor(100/$arguments['columns']) - $margin) : 100 - $margin;

    You say:
    The default style template includes “margin: 1.5%”
    But wp default do not.

    Can a margin_setting = default in your shortcode somehow set the – $maring to 0? (will output default variable value)

    more of the context in your function:

    /*
     * The default style template includes "margin: 1.5%" to put a bit of
     * minimum space between the columns. "mla_margin" can be used to increase
     * this. "mla_itemwidth" can be used with "columns=0" to achieve a "responsive"
     * layout.
     */
    
    		$margin = absint( 2 * (float) $arguments['mla_margin'] );
    		if ( isset ( $arguments['mla_itemwidth'] ) ) {
    			$itemwidth = absint( $arguments['mla_itemwidth'] );
    		}
    		else {
    			$itemwidth = $arguments['columns'] > 0 ? (floor(100/$arguments['columns']) - $margin) : 100 - $margin;
    		}

    I just want the true column itemwith value….

    Plugin Author David Lingren

    (@dglingren)

    Thank you for expanding on your thinking behind the “itemwidth” requirements. I will add something like “exact_itemwidth” to the “substitution parameters” list in my next release.

    Your example adds one decimal place of precision, e.g., .166 or 16.6% for six columns. Is it reasonable to round (or floor) after one or two more places of precision, e.g., 16.66% or 16.67% for six columns? It seems ugly or dangerous to have many additional digits in the result. Unless you have a more specific proposal I will round after two more digits, e.g., 16.67%. Let me know what you think. I could also add some sort of scale specifier, e.g., mla_itemwidth_digits=2,round but that seems like too much complexity.

    By the way, I will also be more clear in my documentation. My first version simply copied the WordPress styles and calculations. I found that with five or more columns this resulted in ugly, overlapping gallery items, so I added a bit of margin to clean it up. I should say “MLA default style” instead of just “default style”.

    Thread Starter Jonas Lundman

    (@jonas-lundman)

    Hi,
    First :

    I will add something like “exact_itemwidth” to the “substitution parameters” list in my next release.

    A checkbox on the template tab would be a smooth solutioon and in right place for humans to understand what it does (eg client editors).

    The lack of a .0x floor in many situations, like 10 column galleries on a screenwidth of 460px (ios) is hardly noticed, just one pixel or so. To always floor the to the 0.x (16,6667777 = 16,6) makes shure Opera and som rotating issues on mobile devices is a little bit more secured.

    Calculating offset for gaps become < or > the floor(ed) deciamal values, and add “16,7” to a single item is overkill, I think. Any diffs in the itemwith will affect the height of the wrapper conatiner, and inle-block styled items can “pull down” just a bad ahndle of 0.05 px by the browser.

    The auto margin added (gutter) right now makes the iOS devices or small screen really unsecured and falls out badly/ mega marginals or breaking floating points. So get rid of the forced variant somehow would be grat for designers who knows CSS, and let presentation be separated from output functionalities.

    I suggest to not add any decimal options in the shortcodes, they will propably never be known, understandable or remembered by Clients, Siteowner editors or none developers who gonna add a MLA shortcode. = real users in the world…

    Maybe just a checkbox option on the template tag again to Use deciamal values on itmewidth, as a global statement.

    Im really digged in to MLA in a current project and gonna send a link for how this itemwidth enhence the mobile experiance and gallery views on desktops etc etc.

    The latest update with mime and wievs are asome. I have more suggetions about the user experiance, like change the order in admin menues, let assistan be first and default diabled or last. Hooks to the assistant table columns, so we can map some other plugin functionalities into the Assistant. Columns like, filesize, width hight, Click on thumbnails open edit, why not in a modal. Missin the View attachment page link somewhere; And most of all, the Quick edit link show under Title or Name only. No client or siteowner knows what a parent ID is and we wanna hide that cluttered data stuff. The latter could be a developer mode of table view.. And much more…

    THX

    Plugin Author David Lingren

    (@dglingren)

    This is helpful information and great suggestions, thanks! I will consider them for upcoming releases. I am very glad you like the MIME and Views additions; they were quite a bit of work but I was happy with the results.

    Regarding a few of your items:

    • Moving and disabling the menu items has come up before, and I am wary about messing with them. Making it a configurable option setting would be safe enough, I guess.
    • Columns like filesize, width, etc. are why the “Custom Fields” tab was created. Values like filesize require additional processing and I didn’t want to incur that overhead on every page view, so pre-computing and storing the value made sense to me.
    • “Click on thumbnails opens edit…” – I decided to be as “WordPress-like” as possible, and that’s what happens for posts/pages and in the WordPress Media/Library screen.
    • Adding a “View” link is a good idea.
    • The Quick Edit and other rollover links will show up in any of four columns. There was a bug in versions before 1.40, and a “Fix: Quick edit data now populates in Title/Name, Title or Name columns when ID/Parent column is hidden.”

    I will study the rest of your post and I look forward to more of your thinking. Thank you.

    Plugin Author David Lingren

    (@dglingren)

    I have released version 1.42, which contains several new features giving more control over the margin and itemwidth attributes of [mla_gallery] items. Margin and itemwidth can now take any valid CSS value, such as “auto” or a fixed quantity such as “10px”. You can remove them from the styles altogether by coding a value of “none”. The Settings/Media Library Assistant MLA Gallery tab lets you assign default values of your choice for these and other parameters.

    I have also added the “View” link to the Media/Assistant submenu table rollover actions. I have your suggestions on moving or replacing the Media menu items on my list to consider for future releases.

    Thank you again for all the time and effort you put into thinking through these issues and discussing them with me. Let me know if you have any problems or further questions regarding the new release.

    Plugin Author David Lingren

    (@dglingren)

    I have released version 1.50, which includes the ability to customize the name, label and title of the Media/Assistant submenu screen. You can also remove the default Media/Library submenu screen.

    Please let me know if you have any problems with or further questions about this new feature. Thanks again for your interest and for your suggestion.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘MLA post_gallery replacement adds extra margin’ is closed to new replies.