Support » Plugin: Media Library Assistant » shortcode within custom page template

  • Resolved elink

    (@elink)


    hello david – like all others, I find your plugin extremely useful. thank you for your efforts.

    I have following shortcode in my custom page template (all pages are generated dynamically) that didn’t give me what I expected. You can see the result here w/ the debug output of the shortcode below and output to the web page. The images are not in the order I specified (in custom field ‘sortorder’); the href is not correct (using alt text and other meta mapped fields, but is still just to the image file); and lastly, I had done a bulk edit to remove the caption, but it still seems to be there. So – what might I be doing wrong here or should check?

    shortcode:

    [mla_gallery attachment_tag="products" orderby="{+custom:sortorder+} ASC" mla_link_href = "{+site_url+}/?pageslug={+image_alt+}&parent=products&title={+title+}&icon={+custom:icon+} columns=5 mla_margin=0.25%]

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

    (@dglingren)

    Thanks for the kind words and for your question. Thanks as well for posting the source text of your shortcode and the link to your page; very helpful.

    You wrote “The images are not in the order I specified …” Sorting on a custom field value has special syntax. Here’s what the “Order, Orderby” section of the Settings/Media library Assistant Documentation states:

    <keyname>, meta_value, meta_value_num – Order by custom field value. Note that a meta_key=keyname must also be present in the query. For example, to sort by a custom field called “Publication Date” and display the most recent items first, code [mla_gallery meta_key=”Publication Date” orderby=meta_value order=DESC]

    For your specific value this would be:

    
    meta_key="sortorder" orderby=meta_value order=ASC
    

    Second, you wrote “the href is not correct“. I see two possible problems with your shortcode: 1) spaces around the “=” after the mla_link_href parameter name and 2) no closing double-quote at the end of the parameter. Try writing the shortcode like this:

    
    [mla_gallery attachment_tag="products" meta_key="sortorder" orderby=meta_value order=ASC mla_link_href="{+site_url+}/?pageslug={+image_alt+}&parent=products&title={+title+}&icon={+custom:icon+}" columns=5 mla_margin=0.25%]
    

    If that does not give you what you want, let me know and I will investigate further.

    Thread Starter elink

    (@elink)

    Thanks. Problems solved. But then I decided to change approach – namely want all needed info stored in originating (JPG) meta data rather than using admin menus to set values — and this of course has led to more confusion.

    I wrote a simple program to invoke the exif_read_data (based on manual example) on my image file (e.g. phone, radio image in prior post url). The output is:

    /opt/wordpress/wp-content/uploads/products-radio.jpg:<br />
    Image contains headers<br />
    FILE.FileName: products-radio.jpg<br />
    FILE.FileDateTime: 1483725849<br />
    FILE.FileSize: 12460<br />
    FILE.FileType: 2<br />
    FILE.MimeType: image/jpeg<br />
    FILE.SectionsFound: ANY_TAG, IFD0, THUMBNAIL, EXIF, WINXP<br />
    COMPUTED.html: width="141" height="130"<br />
    COMPUTED.Height: 130<br />
    COMPUTED.Width: 141<br />
    COMPUTED.IsColor: 1<br />
    COMPUTED.ByteOrderMotorola: 1<br />
    COMPUTED.UserComment: bullhorn<br />
    COMPUTED.UserCommentEncoding: ASCII<br />
    COMPUTED.Thumbnail.FileType: 2<br />
    COMPUTED.Thumbnail.MimeType: image/jpeg<br />
    IFD0.ImageDescription: 2<br />
    IFD0.Software: www.inkscape.org<br />
    IFD0.PixelUnit: <br />
    IFD0.PixelPerUnitX: 1128<br />
    IFD0.PixelPerUnitY: 1128<br />
    IFD0.Exif_IFD_Pointer: 2230<br />
    IFD0.Title: Radio<br />
    IFD0.Keywords: products<br />
    IFD0.Subject: radio<br />
    IFD0.UndefinedTag:0xEA1C: <br />
    THUMBNAIL.Compression: 6<br />
    THUMBNAIL.JPEGInterchangeFormat: 4378<br />
    THUMBNAIL.JPEGInterchangeFormatLength: 1687<br />
    EXIF.UserComment: ASCIIbullhorn<br />
    EXIF.UndefinedTag:0xEA1C: <br />
    WINXP.Title: ?????<br />
    WINXP.Keywords: ????????<br />
    WINXP.Subject: ?????<br />
    

    From above I want to map :

    IFD0.Title: Radio<br /> –> to title query argument in my href string
    IFD0.Subject: radio<br /> –> to pageslug query argument in my href string
    COMPUTED.UserComment: bullhorn<br /> –> to icon query argument in my href string
    IFD0.ImageDescription: 2<br /> –> for image order in the gallery.

    I have tried various mappings and shortcode arguments (am invoking via do_shortcode within my custom page.php script) and haven’t succeeded in getting example (radio) title,icon, and order mapping correctly. Here is latest incarnation:
    [mla_gallery attachment_tag="products" orderby={+exif:ImageDescription+} order=ASC mla_link_href="{+site_url+}/?pageslug={+slug+}&parent=products&title={+exif:Title+}&icon={+image_alt+}" columns=5 mla_margin=0.25%]
    with the following mapping:
    meta mapping

    Plugin Author David Lingren

    (@dglingren)

    Thanks for the good news on your progress and for the detailed description of your new approach. Thanks as well for your patience in awaiting my response while I did some experimenting with the image you gave as an example (products-radio.jpg). The “meta mapping” link seems to be broken.

    The current MLA version does not provide direct access to values in the IFD0 section because it does uses the default false value for the exif_read_data $arrays parameter. I am working on a change for the next MLA version and I appreciate your bringing it to my attention. With $arrays = false, the Title and Subject values from IFD0 are being overwritten by the bad values from the WINXP section. That may be part of your problem. The UserComment value is available as {+exif:COMPUTED.UserComment+}.

    The good news is your file also contains quite a lot of XMP metadata and you can use it as an alternative to the EXIF metadata to get what you want. You can try:

    
    {+xmp:title+} or {+xmp:dc.title+}
    {+xmp:subject+} or {+xmp:dc.subject+}
    

    You can read more about accessing XMP metadata in the Documentation tab.

    Your example shortcode contains orderby={+exif:ImageDescription+}. This will not work because WordPress does not support sorting by anything other than the specific values listed in the MLA Documentation tab. It is not possible to sort by data embedded in the files attached to the Media Library items. You could always map the ImageDescription to a custom field and sort on that.

    I will post an update here when I have completed the MLA enhancement for direct access to the IFD0 metadata. Let me know if you need any other help in the interim.

    Plugin Author David Lingren

    (@dglingren)

    I have released MLA version 2.41, which includes the IFD0 improvements I outlined in an earlier post above. The WINXP values no longer overwrite IFD0 values, but they are instead available in a separate array, e.g., {+exif:WINXP.Title+}.

    You can now reliably access the Title and Subject values as {+exif:Title+} and {+exif:Subject+}. Of course, the XMP values will also work for your application.

    I am marking this topic resolved, but please update it if you have any problems or further questions regarding metadata access. Thanks for inspiring this MLA improvement!

    Thread Starter elink

    (@elink)

    Okay – got new release. The {+exif:Subject+} gives me what I need. Thanks much. Consider closed.

    See the second tab (“ARSLS Program”) at this location.

    I included some variants to see result of href. I could never get the {+xmp:subject+} to give me what I needed.

    The challenge is getting consistency in the source application that is doing the jpg meta data (reminds me of tannenbaum – “the great thing about standard is there are so many to choose from”)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘shortcode within custom page template’ is closed to new replies.