[Xenbros] Auto thread Thumbnail

xF2 Add-on [Xenbros] Auto thread Thumbnail 2.3.5

No permission to download

MEGAHERZ

Collaborate
Collaborate
Registered
Joined
Mar 16, 2019
Messages
50
Points
38

Reputation:

Do either of you have a solution for this? "Template error: [E_WARNING] Undefined variable $baseUrl" if not this addon shouldn't be released for 2.2
@BattleKing @ENXF NET
 

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
3,513
Points
523

Reputation:

View previous replies…

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
3,513
Points
523

Reputation:

think i may be a little slow as I'm not finding it in it

PHP:
<?php

namespace xenbros\Threadthumbnail\Entity;

use XF\Mvc\Entity\Structure;

class Thread extends XFCP_Thread
{
    public function getfirstPostImgUrl()
    {  
        //\XF::dump($this->Forum->Node);
        $ctustom_image_feild = $this->getCustomFields()[$this->Forum->Node->node_custom_image_feild];

        if($ctustom_image_feild)
        {
            return $ctustom_image_feild;
        }

        $enable_first_image_url  = \XF::options()->enable_first_image_url ;

        if($this->discussion_type != 'redirect'){

            if ($enable_first_image_url) {
                $message = $this->FirstPost->message;
                preg_match('/\[IMG(.*?)\](.+?)\[\/IMG\]/i',$message,$matches);

                if($matches)
                {
                        $url = $matches[2];
                        $linkInfo = \XF::app()->stringFormatter()->getLinkClassTarget($url);
                        if ($linkInfo['local'])
                            { return $url; }
                        if(\XF::app()->options()->imageLinkProxy['images'])
                            {
                                $proxyUrl = \XF::app()->stringFormatter()->getProxiedUrlIfActive('image', $url);
                                return $proxyUrl;
                            }
                        return $url;
                }
            }
                $attachments = $this->FirstPost->Attachments;
                foreach ($attachments as &$attachment)
                {
                    //\XF::dump($this->Forum->Node->node_attachment_thumb);

                    if ( $attachment->has_thumbnail == 'TRUE' )
                    {  
                        //\XF::dump($attachment->thumbnail_url);
                        if ($this->Forum->Node->node_attachment_thumb == 'full') {
                             $attachmentUrl = $baseUrl . \XF::app()->router()->buildLink('attachments', $attachment);
                        }
                        else{
                            $attachmentUrl = $attachment->thumbnail_url;
                        }
                        return $attachmentUrl;
                    }

                }

        }
        if ($this->Forum->Node->node_default_thread_thumbnail_image) {
            return $this->Forum->Node->node_default_thread_thumbnail_image ;
        }
        else{
            return \XF::options()->xb_th_default_image ;
        }
    }
}
edit- oh you said baerUrl think u meant baseurl lol
MEGAHERZ
Blok.png


just change that line
PHP:
$attachmentUrl = $baseUrl . \XF::app()->router()->buildLink('attachments', $attachment);
to
PHP:
$attachmentUrl = \XF::app()->router()->buildLink('attachments', $attachment);
 

MEGAHERZ

Collaborate
Collaborate
Registered
Joined
Mar 16, 2019
Messages
50
Points
38

Reputation:

View attachment 31021

just change that line
PHP:
$attachmentUrl = $baseUrl . \XF::app()->router()->buildLink('attachments', $attachment);
to
PHP:
$attachmentUrl = \XF::app()->router()->buildLink('attachments', $attachment);
BattleKingfreakin lifesaver, man; btw I would pin this in the OP or main resource tab, as I'm not the only one with this issue.
 

valid

+Lifetime VIP+
+Lifetime VIP+
V.I.P Member
Registered
Joined
Apr 3, 2020
Messages
188
Points
53

Reputation:

View attachment 31021

just change that line
PHP:
$attachmentUrl = $baseUrl . \XF::app()->router()->buildLink('attachments', $attachment);
to
PHP:
$attachmentUrl = \XF::app()->router()->buildLink('attachments', $attachment);
BattleKingMaking this change eliminates the error but introduced another File heath check results problem..

1701446779572.png
 

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
3,513
Points
523

Reputation:

Making this change eliminates the error but introduced another File heath check results problem..

View attachment 38205
validYou need to recreated the hash control file, but this is the normal behavior if you change one of them. It will be recognized by the system, which is good
 

valid

+Lifetime VIP+
+Lifetime VIP+
V.I.P Member
Registered
Joined
Apr 3, 2020
Messages
188
Points
53

Reputation:

You need to recreated the hash control file, but this is the normal behavior if you change one of them. It will be recognized by the system, which is good
BattleKingCould you please do the hash control file and re-upload it here? I hate to see that error.
 

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
3,513
Points
523

Reputation:

Attachments

  • addon_and_hashes.json.zip
    2.2 KB · Views: 54

Anna

Well-known member
Registered
Joined
May 18, 2020
Messages
139
Points
38

Reputation:

It seems nobody cares for that anymore?

In entity>Thread.php

Code:
// correct links for attachments as thread thumbnail


        //$baseUrl = \XF::app()->request()->getFullBasePath();

        $baseUrl = \XF::app()->options()->boardUrl;


// show guests the default image instead a broken image


        $visitor = \XF::visitor();

        if ($visitor['user_group_id'] == 1)

            return \XF::options()->xb_th_default_image;
 
Last edited:
Top