1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MG 1.1 Edit embed text

Discussion in 'Media Gallery Support' started by Evan Scamman, May 29, 2016.

  1. Evan Scamman

    Evan Scamman New Member

    When I click a media gallery image to insert it into a post, text in the following format is automatically added:

    IMAGE_NAME by USER_NAME posted May 28, 2016 at 11:57 PM

    How can I change this so that the image description is shown and not the user name and upload date?
    Can anyone tell me which file to edit?

    Thank you,
    Evan
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    The phrase is named "xengallery_x_by_y_posted_z".

    That's used in the xengallery_browser_editor_content template.

    You would need to change this:
    Code:
    data-title="{xen:phrase xengallery_x_by_y_posted_z, 'title={$item.media_title}', 'user={$item.username}', 'date={xen:datetime $item.media_date, absolute}'}"
    To this:
    Code:
    data-title="{xen:phrase xengallery_x_by_y_posted_z, 'title={xen:if $item.media_description, $item.media_description, $item.media_title}', 'user={$item.username}', 'date={xen:datetime $item.media_date, absolute}'}"
    Note, it will display a description if there is one, else it will display the title. (Descriptions are optional, titles are not, so it's good to keep that as a fallback).
     
  3. Evan Scamman

    Evan Scamman New Member

    Chris,

    Thanks so much for your answer - and especially for taking the time to write the code.
     
  4. Evan Scamman

    Evan Scamman New Member

    Chris,

    I got things working with only one minor cosmetic issue.
    After the gallery image is embeded, there is a significant amount of white space (about 3 blank lines) before the post continues.
    Is there a way to reduce this? Perhaps by editing the BB_Code template or something?
     
  5. Chris D

    Chris D XenForo Developer Staff Member

    We already trim some leading lines when we render the BB code, and in my testing I can't reproduce any excess white space:
    Code:
    Test
    [GALLERY=media, 1]Logo.og by Chris D posted May 31, 2016 at 7:11 PM[/GALLERY]
    Test
    Produces:
    upload_2016-5-31_19-13-40.png

    Which seems ok to me.
     
  6. Evan Scamman

    Evan Scamman New Member

    Yes, what you have looks fine. Mine is different because I tweaked a couple things.

    embed.jpg


    As you can see, I have a lot of space between the image and the description.
    I changed two things:

    xengallery_browser_editor_content
    BEFORE: data-title="{xen:phrase xengallery_x_by_y_posted_z, 'title={$item.media_title}', 'user={$item.username}', 'date={xen:datetime $item.media_date, absolute}'}"
    AFTER: data-title="{$item.media_description}"

    js/xengallery/min/gallery_bb_code.js
    BEFORE: a="[GALLERY="+a.data("type")+", "+a.data("id")+"]"+XenForo.htmlspecialchars(a.data("title"))+"[/GALLERY]";
    AFTER: a="[GALLERY="+a.data("type")+", "+a.data("id")+"]"+"[/GALLERY]<font size=3>"+a.data("title")+"</font><br><br>";

    I bypassed "xengallery_x_by_posted_z" entirely and used the Description to populate the image title.
    This is a temporary thing because I needed to embed about 1,500 images along with their descriptions.

    What I really want is just the description right below the image, but I was trying to avoid it being hyperlinked (and I wanted to use a smaller font).
     
  7. Chris D

    Chris D XenForo Developer Staff Member

    I would recommend undoing some of the changes you've made to see if that narrows down which has caused the issue.

    It's never recommended to modify core files, so you should revert those changes ASAP. Not least because the specific change you've done actually introduces a security issue known as a XSS vulnerability.

    I should note that the JS code has "<br><br>" at the end so this could explain the extra line breaks.
     
  8. Evan Scamman

    Evan Scamman New Member

    I plan to undo all changes. This was a temporary thing so that I could get 1,500 images embeded. I plan to restore everything to the original now that I'm done.
    Once I do, will it affect all the existing embeds or just subsequent ones?

    The <br><br> is after description text - not before.
     
  9. Chris D

    Chris D XenForo Developer Staff Member

    I'm not totally clear what has caused it, so I can't be sure. Hopefully undoing the changes will put it back to normal.
     
  10. Evan Scamman

    Evan Scamman New Member

    If I mess with the BB code embed template will it affect existing embeds or only future ones?
     

Share This Page