XF 2.2 Exploring Code to Distinguish Normal Requests from Unfurl Requests: Seeking Ways to Differentiate

JohnLogar

Active member
I'm attempting to distinguish between requests made for regular purposes and those specifically for unfurling. I've explored using request.isXhr in the code but haven't been successful in differentiation. The primary objective is to modify the meta description when the request is for unfurling.
 
You can likely just set the og:description meta (though you'd need to duplicate the other values from metadata_macros::description).
 
Thanks for your reply. I was able to achieve what I needed by passing the custom title of og.title to the meta_macros template. Now, I need to replace the site icon with the member profile avatar. Currently, the site icon is being rendered from the PAGE_CONTAINER with the following code:

HTML:
<meta name="apple-mobile-web-app-title" content="{{ $xf.options.boardShortTitle ?: $xf.options.boardTitle }}">
    <xf:if is="property('publicIconUrl')">
        <link rel="apple-touch-icon" href="{{ base_url(property('publicIconUrl', true)) }}">
    <xf:elseif is="property('publicMetadataLogoUrl')" />
        <link rel="apple-touch-icon" href="{{ base_url(property('publicMetadataLogoUrl')) }}" />
    </xf:if>

I want to replace the site icon with the user profile avatar when accessing the member profile URL. I tried copying the same code to the member_view template, but it didn't work.
 
The code you've shown is for setting the PWA icon, which is different from the embed/unfurl icon.

In any case, the metadata_macros::image_url macro should let you customize the embed/unfurl icon.
 
Thanks, I understand. I want to remove the domain URL when it's unfurled on Discord or elsewhere. I tried various options from the meta_macros template but couldn't pinpoint the source.

1717756788576.webp
 
I don't understand the question. The URL is displayed in Discord messages regardless of whether it is unfurled or not, and it's not something they offer any control over as far as I know. There are some security considerations with removing it.
 
I don't understand the question. The URL is displayed in Discord messages regardless of whether it is unfurled or not, and it's not something they offer any control over as far as I know. There are some security considerations with removing it.


On Discord it shows the site name at top in the link embed, the question is how do we go about removing it because I already show it in the bottom title
1719576697338.webp
 
That probably comes from og:site_name, which I would not recommend removing. Discord wants to display the site name there, and does so for every website.
 
Back
Top Bottom