• Resolved Vipa

    (@vipa)


    Hi David,

    I am using MLA to create a gallery of pdf documents, which is working great. Thank you for the plugin.

    I got 2 related problems:
    I have 10 pdf to show and I want to have 6 per row. If one of the caption texts has more lines than the last one in the row, the items in the next row get moved to the right until they are one right of the one with the long caption text.

    likes this:
    s = pdf with short caption
    l = pdf with long caption

    ssslss
        ss
    ss

    Which leads to my second problem, I tried to go around the problem by shortening the caption with substr. Unfortunately it is not working, it returns an empty string for me.

    [mla_gallery attachment_category='vending-report' columns=6 link=file orderby=date order=DESC post_mime_type=application/pdf mla_target='_blank' mla_caption='{+caption,substr(0,20)+}
    ({+custom:File Size,kbmb(t, K, MB,2)+})']

    And when I am already writing. I used the kbmb function and the only argument I wanted to use was p to limit to 2 decimals. But this only worked if i passed all other arguments.
    kbmb(t, K, MB,2)
    I tried to use
    kbmb(,,,2)
    without success.

    Wordpress: 5.2
    Media Assistant: 2.79
    PHP: 7.2.18 FPM

    Unfortunately I cannot link to the site as it is on a development server.

    • This topic was modified 5 years, 10 months ago by Vipa.
    • This topic was modified 5 years, 10 months ago by Vipa.
    • This topic was modified 5 years, 10 months ago by Vipa.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for your detailed description and for the complete text of your source code; very helpful.

    Your first problem is caused by some quirks in the way [mla_gallery] handles non-image items. You can solve it by changing the data source in your substitution value, e.g., try this alternative: {+post_excerpt,substr(0,20)+}. The post_excerpt data source is reliable for non-image items.

    Your second problem is a shortcoming of the way MLA parses missing arguments. You can solve it by substituting the default argument values, e.g., try one of these alternatives: {+custom:File Size,kbmb("",K,MB,2)+} or {+custom:File Size,kbmb(10240,K,MB,2)+}.

    I am not sure why you are using a custom field for the file size. You can try this standard data source: {+file_size,kbmb(10240,K,MB,2)+}.

    Putting it all together, here is an mla_caption parameter that works in my test system:

    mla_caption='{+post_excerpt,substr(0,20)+} ({+file_size,kbmb(10240,K,MB,2)+})'
    

    I hope that gets you the results you need. I am marking this topic resolved, but please update it if you have any problems or further questions regarding the above suggestions. Thanks for your positive feedback on the plugin.

    Thread Starter Vipa

    (@vipa)

    Hi David,

    thanks for your reply!

    all of the above works like a charm and you were right about the custom File Size field, it was not necessary, I thought I had to use a custom filed to use the information.

    Anything I can do about this, so I don′t have to shorten the caption text at all?

    I have 10 pdf to show and I want to have 6 per row. If one of the caption texts has more lines than the last one in the row, the items in the next row get moved to the right until they are one right of the one with the long caption text.

    likes this:
    s = pdf with short caption
    l = pdf with long caption

    ssslss
        ss
    ss

    Thanks again!

    • This reply was modified 5 years, 10 months ago by Vipa.
    Plugin Author David Lingren

    (@dglingren)

    Thanks for confirming that my suggestions were useful.

    Regarding the “moved to the right” behavior, this kind of issue is very theme-specific. For example, on the WordPress “Twenty Nineteen Version: 1.4” theme, content on each row is centered. on the older “Twenty Twelve Version: 3.0” (which does not support HTML5) the problem does not occur.

    The default [mla_gallery] format and styles are modeled after the WordPress [gallery] shortcode. The HTML5-compatible version uses “div”, “figure” and “figcaption” tags, while older themes use “dt”, “dl” and “dd” tags. The older themes separate each row with <br style: clear: both> but the newer themes omit this element.

    You can try making a copy of the “default” markup template, e.g., to “default-copy” and using it (without changes) by coding mla_markup=default-copy. That will restore the row separation elements, which may give you a better result.

    Without access to your specific site and theme I can’t give you more specific guidance, and I am not much of a CSS expert in any case. I hope you will be able to use the above suggestions and dig through your CSS styles to get the results you seek. If you do find an answer, share it here for other MLA users. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘substr function not working’ is closed to new replies.