Problem with XenForo Media Gallery 2.2.5 Share Links

PhantomCrew

New member
Registered
Joined
Sep 24, 2023
Messages
3
Points
3

Reputation:

Hello, I have a problem with XenForo Media Gallery 2.2.5 Share Links

I don't know if it's normal, but I'm getting incorrect links to the uploaded image.
With the links provided I can only post in my own forum, but I would also like to use the link in other forums
This link is issued by the XenForo Media Gallery 2.2.5: https://xxxxxxxxxxx.xx/media/domin.5/full
but the XenForo Media Gallery 2.2.5 saved the file here: https://xxxxxxxxxx.xx/data/xfmg/thumbnail/0/5-41a27622ca41a110c7a36c3533602983.jpg
It should actually output this link. I've searched many forums but haven't found anything about this. I now know that this will or must be a template modification.
I think I have already found the template responsible.

xfmg_media_view_macros The output code starts from line 444
The output line in question is 464, but I have no idea what I have to change it to so that the file link is output to me.

I also found out that the Pinterest share button outputs the correct link/url
Pinterest Code
Code:
<xf:if is="$xf.options.pinterestShare">
<a class="shareButtons-button shareButtons-button--brand shareButtons-button--pinterest" data-href="https://pinterest.com/pin/create/bookmarklet/?url={url}&amp;description={title}&amp;media={image}">
<i aria-hidden="true"></i>
<span>{{ phrase('pinterest') }}</span>
</a>
</xf:if>


Maybe someone knows how it would work.
Code:
xfmg_media_view_macros Code

<xf:macro name="media_status" arg-mediaItem="!" arg-block="{{ true }}">
    <xf:set var="$inner">
        <xf:if contentcheck="true">
            <dl class="blockStatus">
                <dt>{{ phrase('status') }}</dt>
                <xf:contentcheck>
                    <xf:if is="$mediaItem.album_id AND $mediaItem.Album AND $mediaItem.Album.album_state == 'deleted'">
                        <dd class="blockStatus-message blockStatus-message--deleted">
                            {{ phrase('xfmg_media_item_is_contained_within_deleted_album') }}
                            <xf:macro template="deletion_macros" name="notice" arg-log="{$mediaItem.Album.DeletionLog}" />
                        </dd>
                    </xf:if>
                    <xf:if is="$mediaItem.media_state == 'deleted'">
                        <dd class="blockStatus-message blockStatus-message--deleted">
                            {{ phrase('xfmg_media_item_is_deleted') }}
                            <xf:macro template="deletion_macros" name="notice" arg-log="{$mediaItem.DeletionLog}" />
                        </dd>
                        <xf:elseif is="$mediaItem.media_state == 'moderated'" />
                        <dd class="blockStatus-message blockStatus-message--moderated">
                            {{ phrase('awaiting_approval_before_being_displayed_publicly') }}
                        </dd>
                    </xf:if>
                    <xf:if is="$mediaItem.warning_message">
                        <dd class="blockStatus-message blockStatus-message--warning">
                            {$mediaItem.warning_message}
                        </dd>
                    </xf:if>
                    <xf:if is="$mediaItem.isIgnored()">
                        <dd class="blockStatus-message blockStatus-message--ignored">
                            {{ phrase('you_are_ignoring_content_by_this_member') }}
                        </dd>
                    </xf:if>
                </xf:contentcheck>
            </dl>
        </xf:if>
    </xf:set>
    <xf:if is="$row">
        <div class="block">
            <div class="block-outer">
                {$inner|raw}
            </div>
        </div>
    <xf:else />
        {$inner|raw}
    </xf:if>
</xf:macro>

<xf:macro name="media_content" arg-mediaItem="!" arg-mediaNotes="{{ [] }}" arg-linkMedia="{{ false }}">
    <xf:if is="$mediaItem.media_type == 'image'">
        <div class="media-container-image js-mediaContainerImage">
            <xf:foreach loop="$mediaNotes" value="$note">
                <xf:macro name="note_view" arg-mediaItem="{$mediaItem}" arg-note="{$note}" />
            </xf:foreach>
            <xf:set var="$imageHtml">
                <img src="{{ link('media/full', $mediaItem, {'d': $mediaItem.last_edit_date ?: null}) }}"
                     width="{$mediaItem.Attachment.width}" height="{$mediaItem.Attachment.height}"
                     alt="{$mediaItem.title}" class="js-mediaImage" />
            </xf:set>
            <xf:if is="$linkMedia">
                <a href="{{ link('media', $mediaItem) }}">{$imageHtml|raw}</a>
            <xf:else />
                {$imageHtml|raw}
            </xf:if>
        </div>
    <xf:elseif is="$mediaItem.media_type == 'video'" />
        <div class="bbMediaWrapper">
            <div class="bbMediaWrapper-inner">
                <video preload="metadata" controls poster="{$mediaItem.poster_url}" data-video-type="video">
                    <source src="{$mediaItem.getVideoUrl()}" type="video/mp4" />
                    <div class="bbMediaWrapper-fallback">{{ phrase('your_browser_is_not_able_to_display_this_video') }}</div>
                </video>
            </div>
        </div>
    <xf:elseif is="$mediaItem.media_type == 'audio'" />
        <xf:set var="$audioItem">
            <video preload="metadata" controls poster="{$mediaItem.poster_url}" data-video-type="audio">
                <source src="{$mediaItem.getAudioUrl()}" type="audio/mpeg" />
                <div class="bbMediaWrapper-fallback">{{ phrase('xfmg_your_browser_is_not_able_to_play_this_audio') }}</div>
            </video>
        </xf:set>

        <xf:if is="$mediaItem.hasPoster() OR $mediaItem.hasThumbnail()">
            <div class="bbMediaWrapper">
                <div class="bbMediaWrapper-inner">
                    {$audioItem|raw}
                </div>
            </div>
        <xf:else />
            {$audioItem|raw}
        </xf:if>
    <xf:elseif is="$mediaItem.media_type == 'embed'" />
        {{ bb_code($mediaItem.media_tag, 'xfmg_media', $mediaItem) }}
    </xf:if>
</xf:macro>

<xf:macro name="media_film_strip" arg-mediaItem="!" arg-filmStripParams="!">
    <xf:if is="$filmStripParams.mediaItems is not empty">
        <xf:js src="xfmg/film_strip.js" min="1" />
        <xf:css src="xfmg_media_list.less" />

        <div class="block-outer">
            <div class="block-outer-middle">
                <div class="itemList itemList--strip js-filmStrip">
                    <a data-xf-click="inserter" data-replace=".js-filmStrip"
                        tabindex="0" role="button"
                        data-inserter-href="{{ link('media/film-strip-jump', $mediaItem, {'direction': 'prev', 'jump_from_id': $filmStripParams.firstItem.media_id}) }}"
                        rel="nofollow"
                        class="js-filmStrip-button itemList-button itemList-button--prev{{ !$filmStripParams.hasPrev ? ' is-disabled' : '' }}">

                        <i class="itemList-button-icon"></i>
                    </a>

                    <xf:foreach loop="$filmStripParams.mediaItems" value="$item">
                        <div class="js-filmStrip-item itemList-item">
                            <a href="{{ link('media', $item) }}">
                                {{ xfmg_thumbnail($item, 'xfmgThumbnail--fluid xfmgThumbnail--iconSmallest' . ($item.media_id == $mediaItem.media_id ? ' is-selected': ''), true) }}
                            </a>
                        </div>
                    </xf:foreach>

                    <a data-xf-click="inserter" data-replace=".js-filmStrip"
                        tabindex="0" role="button"
                        data-inserter-href="{{ link('media/film-strip-jump', $mediaItem, {'direction': 'next', 'jump_from_id': $filmStripParams.lastItem.media_id}) }}"
                        rel="nofollow"
                        class="js-filmStrip-button itemList-button itemList-button--next{{ !$filmStripParams.hasNext ? ' is-disabled' : '' }}">

                        <i class="itemList-button-icon"></i>
                    </a>
                </div>
            </div>
        </div>
    </xf:if>
</xf:macro>

<xf:macro name="media_film_strip_placeholders" arg-count="!">
    <xf:if is="$count">
        <xf:foreach loop="{{ range(1, $count) }}" value="$null">
            <div class="js-filmStrip-item itemList-item itemList-item--placeholder">
                <img src="{{ transparent_img() }}" />
            </div>
        </xf:foreach>
    </xf:if>
</xf:macro>

<xf:macro name="note_view" arg-mediaItem="!" arg-note="!">
    <div class="mediaNote js-mediaNote"
        data-note-data="{$note.note_data|json}"
        data-note-id="{$note.note_id}"></div>
    <div class="mediaNote-tooltip js-mediaNoteTooltip{$note.note_id}">
        <div class="noteTooltip-row">
            <xf:if is="$note.note_type == 'note'">
                {{ structured_text($note.note_text) }}
            <xf:elseif is="$note.note_type == 'user_tag'" />
                <div class="contentRow contentRow--alignMiddle">
                    <div class="contentRow-figure">
                        <xf:avatar user="$note.TaggedUser" defaultname="{$note.username}" size="xs" />
                    </div>
                    <div class="contentRow-main contentRow-main--close">
                        <xf:username user="$note.TaggedUser" defaultname="{$note.username}" rich="true" />
                        <xf:if is="$note.TaggedUser">
                            <div class="contentRow-minor">
                                <xf:usertitle user="$note.TaggedUser" />
                            </div>
                        </xf:if>
                    </div>
                </div>
            </xf:if>
        </div>
        <div class="noteTooltip-footer noteTooltip-footer--smallest">
            <ul class="listInline listInline--bullet">
                <li><xf:fa icon="fa-user" title="{{ phrase('xfmg_note_by')|for_attr }}" /> <xf:username user="{$note.User}" defaultname="{$note.username}" class="u-concealed" /></li>
                <xf:if is="$note.canApproveReject()">
                    <li>
                        <xf:fa icon="fa-check" title="{{ phrase('approve')|for_attr }}" />
                        <a href="{{ link('media/note-approve', $mediaItem, {'note_id': $note.note_id, 't': csrf_token()}) }}"
                            class="u-concealed">
                            {{ phrase('approve') }}
                        </a>
                    </li>
                    <li>
                        <xf:fa icon="fa-times" title="{{ phrase('reject')|for_attr }}" />
                        <a href="{{ link('media/note-reject', $mediaItem, {'note_id': $note.note_id, 't': csrf_token()}) }}"
                            class="u-concealed">
                            {{ phrase('reject') }}
                        </a>
                    </li>
                <xf:elseif is="$note.canEdit()" />
                    <li><xf:fa icon="fa-pencil" title="{{ phrase('edit')|for_attr }}" /> <a href="javascript:" class="u-concealed js-mediaNoteTooltipEdit">{{ phrase('edit') }}</a></li>
                </xf:if>
            </ul>
        </div>
    </div>
</xf:macro>

<xf:macro name="info_sidebar" arg-mediaItem="!" arg-row="{{ true }}">
    <xf:set var="$info">
        <xf:if is="$mediaItem.Category">
            <dl class="pairs pairs--justified">
                <dt>{{ phrase('xfmg_category') }}</dt>
                <dd><a href="{{ link('media/categories', $mediaItem.Category) }}">{$mediaItem.Category.title}</a></dd>
            </dl>
        </xf:if>
        <xf:if is="$mediaItem.Album">
            <dl class="pairs pairs--justified">
                <dt>{{ phrase('xfmg_album') }}</dt>
                <dd><a href="{{ link('media/albums', $mediaItem.Album) }}">{$mediaItem.Album.title}</a></dd>
            </dl>
        </xf:if>

        <dl class="pairs pairs--justified">
            <dt>{{ phrase('xfmg_added_by') }}</dt>
            <dd><xf:username user="{$mediaItem.User}" defaultname="{$mediaItem.username}" /></dd>
        </dl>

        <dl class="pairs pairs--justified">
            <dt>{{ phrase('xfmg_date_added') }}</dt>
            <dd><xf:date time="{$mediaItem.media_date}" /></dd>
        </dl>

        <dl class="pairs pairs--justified">
            <dt>{{ phrase('xfmg_view_count') }}</dt>
            <dd>{$mediaItem.view_count|number}</dd>
        </dl>

        <dl class="pairs pairs--justified">
            <dt>{{ phrase('xfmg_comment_count') }}</dt>
            <dd>{$mediaItem.comment_count|number}</dd>
        </dl>

        <dl class="pairs pairs--justified">
            <dt>{{ phrase('rating') }}</dt>
            <dd>
                <xf:macro template="rating_macros" name="stars_text"
                    arg-rating="{$mediaItem.rating_avg}"
                    arg-count="{$mediaItem.rating_count}"
                    arg-rowClass="ratingStarsRow--textBlock" />
            </dd>
        </dl>

        <xf:macro template="custom_fields_macros" name="custom_fields_view"
            arg-type="xfmgMediaFields"
            arg-group="below_info"
            arg-onlyInclude="{{ $mediaItem.category_id ? $mediaItem.Category.field_cache : $mediaItem.Album.field_cache }}"
            arg-set="{$mediaItem.custom_fields}"
            arg-valueClass="pairs pairs--justified" />
    </xf:set>

    <xf:if is="$row">
        <div class="block">
            <div class="block-container">
                <h3 class="block-minorHeader">{{ phrase('xfmg_media_information') }}</h3>
                <div class="block-body block-row">
                    {$info|raw}
                </div>
            </div>
        </div>
    <xf:else />
        {$info|raw}
    </xf:if>
</xf:macro>

<xf:macro name="extra_info_sidebar" arg-mediaItem="!" arg-row="{{ true }}">
    <xf:set var="$info">
        <xf:macro template="custom_fields_macros" name="custom_fields_view"
            arg-type="xfmgMediaFields"
            arg-group="extra_info_sidebar_block"
            arg-onlyInclude="{{ $mediaItem.category_id ? $mediaItem.Category.field_cache : $mediaItem.Album.field_cache }}"
            arg-set="{$mediaItem.custom_fields}"
            arg-valueClass="pairs pairs--justified" />
    </xf:set>
    <xf:if is="$row">
        <xf:if contentcheck="true">
            <div class="block">
                <div class="block-container">
                    <h3 class="block-minorHeader">{{ phrase('xfmg_extra_information') }}</h3>
                    <div class="block-body block-row">
                        <xf:contentcheck>
                            {$info|raw}
                        </xf:contentcheck>
                    </div>
                </div>
            </div>
        </xf:if>
    <xf:else />
        {$info|raw}
    </xf:if>
</xf:macro>

<xf:macro name="additional_sidebar" arg-mediaItem="!">
    <xf:if contentcheck="true">
        <xf:contentcheck>
            <xf:foreach loop="$mediaItem.getExtraFieldBlocks()" key="$fieldId" value="$definition">
                <xf:if is="$definition.hasValue({$mediaItem.custom_fields.{$fieldId}})">
                    <div class="block">
                        <div class="block-container">
                            <h3 class="block-minorHeader">{$definition.title}</h3>
                            <div class="block-body block-row">
                                <xf:macro template="custom_fields_macros" name="custom_field_value"
                                    arg-definition="{$definition}"
                                    arg-value="{$mediaItem.custom_fields.{$fieldId}}" />
                            </div>
                        </div>
                    </div>
                </xf:if>
            </xf:foreach>
        </xf:contentcheck>
    </xf:if>
</xf:macro>

<xf:macro name="exif_sidebar" arg-mediaItem="!" arg-row="{{ true }}">
    <xf:if is="$mediaItem.exif_data">
        <xf:set var="$info">
            <xf:if is="$mediaItem.exif.device">
                <dl class="pairs pairs--justified">
                    <dt>{{ phrase('xfmg_exif.device') }}</dt>
                    <dd>
                        {$mediaItem.exif.device}
                    </dd>
                </dl>
            </xf:if>
            <xf:if is="$mediaItem.exif.aperture">
                <dl class="pairs pairs--justified">
                    <dt>{{ phrase('xfmg_exif.aperture') }}</dt>
                    <dd>
                        {$mediaItem.exif.aperture}
                    </dd>
                </dl>
            </xf:if>
            <xf:if is="$mediaItem.exif.focal">
                <dl class="pairs pairs--justified">
                    <dt>{{ phrase('xfmg_exif.focal') }}</dt>
                    <dd>
                        {$mediaItem.exif.focal}
                    </dd>
                </dl>
            </xf:if>
            <xf:if is="$mediaItem.exif.exposure">
                <dl class="pairs pairs--justified">
                    <dt>{{ phrase('xfmg_exif.exposure') }}</dt>
                    <dd>
                        {$mediaItem.exif.exposure}
                    </dd>
                </dl>
            </xf:if>
            <xf:if is="$mediaItem.exif.iso">
                <dl class="pairs pairs--justified">
                    <dt>{{ phrase('xfmg_exif.iso') }}</dt>
                    <dd>
                        {$mediaItem.exif.iso}
                    </dd>
                </dl>
            </xf:if>
            <xf:if is="$mediaItem.exif.flash">
                <dl class="pairs pairs--justified">
                    <dt>{{ phrase('xfmg_exif.flash') }}</dt>
                    <dd>
                        {$mediaItem.exif.flash}
                    </dd>
                </dl>
            </xf:if>
            <xf:if is="$mediaItem.exif.FileName">
                <dl class="pairs pairs--justified">
                    <dt>{{ phrase('xfmg_exif.filename') }}</dt>
                    <dd>
                        {$mediaItem.Attachment.Data.filename}
                    </dd>
                </dl>
            </xf:if>
            <xf:if is="$mediaItem.exif.file_size">
                <dl class="pairs pairs--justified">
                    <dt>{{ phrase('xfmg_exif.file_size') }}</dt>
                    <dd>
                        {$mediaItem.exif.file_size}
                    </dd>
                </dl>
            </xf:if>
            <xf:if is="$mediaItem.exif.date_taken">
                <dl class="pairs pairs--justified">
                    <dt>{{ phrase('xfmg_exif.date_taken') }}</dt>
                    <dd>
                        {$mediaItem.exif.date_taken}
                    </dd>
                </dl>
            </xf:if>
            <xf:if is="$mediaItem.exif.dimensions">
                <dl class="pairs pairs--justified">
                    <dt>{{ phrase('xfmg_exif.dimensions') }}</dt>
                    <dd>
                        {$mediaItem.exif.dimensions}
                    </dd>
                </dl>
            </xf:if>
        </xf:set>
        <xf:if is="$row">
            <xf:if contentcheck="true">
                <div class="block">
                    <div class="block-container">
                        <h3 class="block-minorHeader">{{ phrase('xfmg_image_metadata') }}</h3>
                        <div class="block-body block-row">
                            <xf:contentcheck>
                                {$info|raw}
                            </xf:contentcheck>
                        </div>
                    </div>
                </div>
            </xf:if>
        <xf:else />
            {$info|raw}
        </xf:if>
    </xf:if>
</xf:macro>

<xf:macro name="user_tags_sidebar" arg-mediaNotes="!">
    <xf:if contentcheck="true">
        <div class="block">
            <div class="block-container">
                <h3 class="block-minorHeader">{{ phrase('xfmg_tagged_in_this_image...') }}</h3>
                <div class="block-body">
                    <xf:contentcheck>
                        <xf:foreach loop="$mediaNotes" value="$note">
                            <xf:if is="$note.note_type == 'user_tag' AND $note.tag_state == 'approved'">
                                <li class="block-row">
                                    <div class="contentRow">
                                        <div class="contentRow-figure">
                                            <xf:avatar user="$note.TaggedUser" defaultname="{$note.username}" size="xs" />
                                        </div>
                                        <div class="contentRow-main contentRow-main--close">
                                            <xf:username user="$note.TaggedUser" defaultname="{$note.username}" rich="true" />
                                            <div class="contentRow-minor">
                                                <xf:usertitle user="$note.TaggedUser" />
                                            </div>
                                        </div>
                                    </div>
                                </li>
                            </xf:if>
                        </xf:foreach>
                    </xf:contentcheck>
                </div>
            </div>
        </div>
    </xf:if>
</xf:macro>

<xf:macro name="share_sidebar" arg-mediaItem="!" arg-row="{{ true }}">
    <xf:if contentcheck="true">
        <div class="block">
            <div class="block-container">
                <xf:contentcheck>
                    <xf:if contentcheck="true">
                        <h3 class="block-minorHeader">{{ phrase('xfmg_share_this_media') }}</h3>
                        <div class="block-body block-row block-row--separated">
                            <xf:contentcheck>
                                <xf:macro template="share_page_macros" name="buttons"
                                    arg-iconic="{{ true }}" />
                            </xf:contentcheck>
                        </div>
                    </xf:if>
                    <xf:if contentcheck="true">
                        <div class="block-body block-row block-row--separated">
                            <xf:contentcheck>
                                <xf:if is="$mediaItem.media_type == 'image'">
                                    <xf:macro template="share_page_macros" name="share_clipboard_input"
                                        arg-label="{{ phrase('xfmg_copy_image_link') }}"
                                        arg-text="{{ link('canonical:media/full', $mediaItem) }}"
                                        arg-successText="{{ phrase('link_copied_to_clipboard') }}" />

                                    <xf:macro template="share_page_macros" name="share_clipboard_input"
                                        arg-label="{{ phrase('xfmg_copy_image_bb_code') }}"
                                        arg-text="[IMG width=&quot;{{ $mediaItem.Attachment.Data.width }}px&quot; height=&quot;{{ $mediaItem.Attachment.Data.height }}px&quot;]{{ link('canonical:media/full', $mediaItem) }}[/IMG]" />
                                <xf:elseif is="$mediaItem.media_type == 'embed'" />
                                    <xf:macro template="share_page_macros" name="share_clipboard_input"
                                        arg-label="{{ phrase('xfmg_copy_media_bb_code') }}"
                                        arg-text="{$mediaItem.media_tag}" />
                                </xf:if>

                                <xf:if is="$mediaItem.thumbnail_date">
                                    <xf:macro template="share_page_macros" name="share_clipboard_input"
                                        arg-label="{{ phrase('xfmg_copy_url_bb_code_with_thumbnail') }}"
                                        arg-text="[URL=&quot;{{ link('canonical:media', $mediaItem) }}&quot;][IMG width=&quot;{{ $xf.options.xfmgThumbnailDimensions.width }}px&quot; height=&quot;{{ $xf.options.xfmgThumbnailDimensions.height }}px&quot;]{$mediaItem.getCurrentThumbnailUrl(true)}[/IMG][/URL]" />
                                </xf:if>

                                <xf:macro template="share_page_macros" name="share_clipboard_input"
                                    arg-label="{{ phrase('xfmg_copy_gallery_bb_code') }}"
                                    arg-text="[GALLERY=media, {$mediaItem.media_id}][/GALLERY]" />
                            </xf:contentcheck>
                        </div>
                    </xf:if>
                </xf:contentcheck>
            </div>
        </div>
    </xf:if>
</xf:macro>
 

Linda

Well-known member
Registered
Joined
Oct 22, 2021
Messages
110
Points
38

Reputation:

It looks like you have posted the XF (XenForo) code for various macros related to media management in the XenForo Media Gallery (XF Media Gallery) system. These macros are responsible for displaying various components and functions related to media files, such as displaying media status, displaying media content (images, videos, audio), managing filmstrips, displaying notes, presenting media information in sidebars and editing various functions.

Option 1: Direct link to the image

If you want the image link to point directly to the full-screen view of the image, you can change the line that creates the image link. Here is one possible customization:

PHP:
<img src="{{ link('media/full', $mediaItem, {'d': $mediaItem.last_edit_date ?: null}) }}"
     width="{$mediaItem.Attachment.width}" height="{$mediaItem.Attachment.height}"
     alt="{$mediaItem.title}" class="js-mediaImage" />

Option 2: Link to another destination

If you want to change the image link to another page or view, replace the entire <a>block with the desired link. For example:

PHP:
<a href="{{ link('dein/neuer/link') }}">
    <img src="{{ link('media/full', $mediaItem, {'d': $mediaItem.last_edit_date ?: null}) }}"
         width="{$mediaItem.Attachment.width}" height="{$mediaItem.Attachment.height}"
         alt="{$mediaItem.title}" class="js-mediaImage" />
</a>

The updated code is part of a condition block (<xf:if>) that checks whether the pinterestShare option is enabled in the XF options. If so, a share button will appear on Pinterest. Here's what the code does:
The <xf:if is="$xf.options.pinterestShare"> block checks whether the Pinterest sharing option is enabled in the XenForo options.
If the condition is met, the button is displayed.
The button has a link (data-href) that is used to create a Pinterest bookmark. This link contains placeholders for url, title and image, which are dynamically replaced by the values of the respective variables.
You want to change the image link. That's why I inserted YOUR_NEW_BILD_LINK as a placeholder for the image link. Replace this placeholder with the actual link to your image.
The button displays a Pinterest icon and has the text "pinterest". Overall, when Pinterest sharing is enabled, this code allows adding a share to Pinterest button with the image link generated dynamically.
 

Linda

Well-known member
Registered
Joined
Oct 22, 2021
Messages
110
Points
38

Reputation:

here are the changes to the original code you posted:

PHP:
<xf:macro name="media_status" arg-mediaItem="!" arg-block="{{ true }}">
    <xf:set var="$inner">
        <xf:if contentcheck="true">
            <dl class="blockStatus">
                <dt>{{ phrase('status') }}</dt>
                <xf:contentcheck>
                    <xf:if is="$mediaItem.album_id AND $mediaItem.Album AND $mediaItem.Album.album_state == 'deleted'">
                        <dd class="blockStatus-message blockStatus-message--deleted">
                            {{ phrase('xfmg_media_item_is_contained_within_deleted_album') }}
                            <xf:macro template="deletion_macros" name="notice" arg-log="{$mediaItem.Album.DeletionLog}" />
                        </dd>
                    </xf:if>
                    <xf:if is="$mediaItem.media_state == 'deleted'">
                        <dd class="blockStatus-message blockStatus-message--deleted">
                            {{ phrase('xfmg_media_item_is_deleted') }}
                            <xf:macro template="deletion_macros" name="notice" arg-log="{$mediaItem.DeletionLog}" />
                        </dd>
                        <xf:elseif is="$mediaItem.media_state == 'moderated'" />
                        <dd class="blockStatus-message blockStatus-message--moderated">
                            {{ phrase('awaiting_approval_before_being_displayed_publicly') }}
                        </dd>
                    </xf:if>
                    <xf:if is="$mediaItem.warning_message">
                        <dd class="blockStatus-message blockStatus-message--warning">
                            {$mediaItem.warning_message}
                        </dd>
                    </xf:if>
                    <xf:if is="$mediaItem.isIgnored()">
                        <dd class="blockStatus-message blockStatus-message--ignored">
                            {{ phrase('you_are_ignoring_content_by_this_member') }}
                        </dd>
                    </xf:if>
                </xf:contentcheck>
            </dl>
        </xf:if>
    </xf:set>
    <xf:if is="$row">
        <div class="block">
            <div class="block-outer">
                {$inner|raw}
            </div>
        </div>
    <xf:else />
        {$inner|raw}
    </xf:if>
</xf:macro>

<xf:macro name="media_content" arg-mediaItem="!" arg-mediaNotes="{{ [] }}" arg-linkMedia="{{ false }}">
    <xf:if is="$mediaItem.media_type == 'image'">
        <div class="media-container-image js-mediaContainerImage">
            <xf:foreach loop="$mediaNotes" value="$note">
                <xf:macro name="note_view" arg-mediaItem="{$mediaItem}" arg-note="{$note}" />
            </xf:foreach>
            <xf:set var="$imageHtml">
                <!-- Hier ist die Änderung -->
                <a href="DEIN_NEUER_BILD_LINK">
                    <img src="{{ link('media/full', $mediaItem, {'d': $mediaItem.last_edit_date ?: null}) }}"
                         width="{$mediaItem.Attachment.width}" height="{$mediaItem.Attachment.height}"
                         alt="{$mediaItem.title}" class="js-mediaImage" />
                </a>
                <!-- Ende der Änderung -->
            </xf:set>
            <xf:if is="$linkMedia">
                <a href="{{ link('media', $mediaItem) }}">{$imageHtml|raw}</a>
            <xf:else />
                {$imageHtml|raw}
            </xf:if>
        </div>
    <!-- Rest des Codes bleibt unverändert -->
</xf:macro>

<!-- Weitere Makros hier einfügen, falls vorhanden -->

<xf:macro name="share_sidebar" arg-mediaItem="!" arg-row="{{ true }}">
    <xf:if contentcheck="true">
        <div class="block">
            <div class="block-container">
                <xf:contentcheck>
                    <xf:if contentcheck="true">
                        <h3 class="block-minorHeader">{{ phrase('xfmg_share_this_media') }}</h3>
                        <div class="block-body block-row block-row--separated">
                            <xf:contentcheck>
                                <!-- Pinterest-Teilen-Schaltfläche hier einfügen -->
                                <xf:if is="$xf.options.pinterestShare">
                                    <a class="shareButtons-button shareButtons-button--brand shareButtons-button--pinterest"
                                       data-href="https://pinterest.com/pin/create/bookmarklet/?url={url}&amp;description={title}&amp;media=DEIN_NEUER_BILD_LINK">
                                        <i aria-hidden="true"></i>
                                        <span>{{ phrase('pinterest') }}</span>
                                    </a>
                                </xf:if>
                                <!-- Ende Pinterest-Teilen-Schaltfläche -->
                            </xf:contentcheck>
                        </div>
                    </xf:if>
                    <xf:if contentcheck="true">
                        <div class="block-body block-row block-row--separated">
                            <xf:contentcheck>
                                <!-- Weitere Teilen-Schaltflächen hier einfügen, falls gewünscht -->
                            </xf:contentcheck>
                        </div>
                    </xf:if>
                </xf:contentcheck>
            </div>
        </div>
    </xf:if>
</xf:macro>
 

PhantomCrew

New member
Registered
Joined
Sep 24, 2023
Messages
3
Points
3

Reputation:

Hello Linda,
First of all, thank you very much for your work and answer.
Unfortunately I'm a PhP beginner, when I insert your code into the template I only see the image on the page again, unfortunately the link remains the same.
I would like to change this in the macro xfmg_media_view_macros in the line arg-text="{{ link('canonical:media/full', $mediaItem) }}" so that not the link to the media gallery image is output but the URL to the image on it Server.

Yes, it is the macro, since the templated only refers to the macro

xfmg_media_view
Code:
    <xf:sidebar key="shareSidebar">
        <xf:macro template="xfmg_media_view_macros" name="share_sidebar" arg-mediaItem="{$mediaItem}" />
    </xf:sidebar>
 
Top