Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

IndexDiscussionImage also for drafts?

Hi @vrijvlinder , any chance that you upgrade your plugin any time soon that it shows also the images for the drafts page?

Comments

  • Not sure if it is possible. Why would you want that ?

  • edited August 2016

    @keesha

    You could try adding this function after the DiscussionsController function. Report if it works

    // Trigger on Drafts.
       public function DraftsController_BeforeDiscussionContent_Handler($Sender) {
            $CssItem = $Sender->EventArguments['CssClass'];
            $CssItem = str_replace("Bookmarked"," ",$CssItem);
            $bodyLine = $Sender->EventArguments['Discussion']->Body;    
            $formline = strip_tags(str_replace(array('[',']'), array('<','>'), $bodyLine));   
            $sline = substr($formline, 0, 220) . "..." ;
            $oldName = $Sender->EventArguments['Discussion']->Name;
            $oldUrl = $Sender->EventArguments['Discussion']->Url;
            $ImageSrc = C('Plugin.IndexDiscussionImage.Image',Url('plugins/IndexDiscussionImage/design/images/default.png'));
            preg_match('#\<img.+?src="([^"]*).+?\>#s', $Sender->EventArguments['Discussion']->Body, $images);
            if ($images[1]) {
                $ImageSrc = $images[1];
            }
            $newTitleAnchor  = '<a class="IndexImage" href="' . $Sender->EventArguments['Discussion']->Url  . '">' .  Img($ImageSrc,  array('title' => $sline, 'class' => "IndexImage")) . '</a>';
           echo "$newTitleAnchor";
       }
    
  • Hi, thanks a ton i'll try this ASAP when i'm back home.

  • No errors but also sadly no images.

    I've also tried to change
    $ImageSrc = C('Plugin.IndexDiscussionImage.Image',Url('plugins/IndexDiscussionImage/design/images/default.png'));

    to

    $ImageSrc = C('Plugin.IndexDiscussionImage.Image','/plugins/IndexDiscussionImage/design/images/default.png');

    but also no luck.

    Any more clues?

  • Do the drafts contain images? This only works on discussions that have an image saved inserted .

  • It can't work for drafts because a draft is not a saved discussion. The way this plugin works is it finds an image saved with the discussion. A draft is not a discussion yet. The list of drafts that appears is just a link to the editor to be able to post it. When you decide to post it, the images you left in the draft will be saved and then they will appear but only on posted discussions.

    You can make it work in the profile when people click MyDiscussions

     // Trigger on Profile
       public function ProfileController_BeforeDiscussionContent_Handler($Sender) {
            $CssItem = $Sender->EventArguments['CssClass'];
            $CssItem = str_replace("Bookmarked"," ",$CssItem);
            $bodyLine = $Sender->EventArguments['Discussion']->Body;    
            $formline = strip_tags(str_replace(array('[',']'), array('<','>'), $bodyLine));   
            $sline = substr($formline, 0, 220) . "..." ;
            $oldName = $Sender->EventArguments['Discussion']->Name;
            $oldUrl = $Sender->EventArguments['Discussion']->Url;
            $ImageSrc = C('Plugin.IndexDiscussionImage.Image',Url('plugins/IndexDiscussionImage/design/images/default.png'));
            preg_match('#\<img.+?src="([^"]*).+?\>#s', $Sender->EventArguments['Discussion']->Body, $images);
            if ($images[1]) {
                $ImageSrc = $images[1];
            }
            $newTitleAnchor  = '<a class="IndexImage" href="' . $Sender->EventArguments['Discussion']->Url  . '">' .  Img($ImageSrc,  array('title' => $sline, 'class' => "IndexImage")) . '</a>';
           echo "$newTitleAnchor";
       }
    

    Remember to save the default image in case there is no image. That is done in the dashboard.

  • Alright, thanks a ton vrijvlinder i appreciate your help a lot :)

Sign In or Register to comment.