Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Vanilla 2.6 is here! It includes security fixes and requires PHP 7.0. We have therefore ALSO released Vanilla 2.5.2 with security patches if you are still on PHP 5.6 to give you additional time to upgrade.
Please upgrade to 2.3 here. The 2.2 and earlier branches are no longer being updated.

I want to disable image embedding in Advanced editor

xm1xm1 New
edited November 2015 in Vanilla 2.0 - 2.3

I just want people to upload images not embed or hotlink them. Basically I want to remove the Image URL input field below the attach image/file dropdown in Advanced Editor.

I looked inside the plugin source and found this:

public function getAllowedEditorActions() {
        static $allowedEditorActions = array(
         ...
         'sep-media' => true, // separator
         'emoji' => true,
         'links' => true,
         'images' => true,
         'uploads' => true,
        ...
        );
        return $allowedEditorActions;
}

But setting 'images' => false didn't do the trick.

Comments

  • peregrineperegrine MVP
    edited November 2015

    if you want to cosmetically remove the option it via css.

    .editor-file-image .image-input { display:none !important; }

    if you want to prevent them from manually adding links that is another story, you will need to write a plugin to remove img tags from the posts.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited November 2015

    you could test this in a plugin not sure if it works can't test. I won't be able to help further on this.

    <?php 
    $PluginInfo['RemoveImage'] = array(
       'Description' => 'This plugin removes images and placed image tags within posts',
       'Version' => '1.0',
       'MobileFriendly' => TRUE,
    );
    
    class RemoveImagePlugin extends Gdn_Plugin {
      public function DiscussionController_AfterCommentFormat_Handler($sender) {
        $this->RemoveImages($sender);
        }
    
      public function PostController_AfterCommentFormat_Handler($sender) {
       $this->RemoveImages($sender);
        }
    
    // get rid of images but keep emoji classed images,
    private function RemoveImages($sender) {
        $body = $sender->EventArguments['Object']->FormatBody;
        $emojiA = '<img class="emoji';
        $emojiB = '<zmg class="emoji';
        $newbody = preg_replace("#\\" . $emojiA . "#si" ,$emojiB , $body);
        $pattern = '#\<img.*?\>#si';
        $newbody = preg_replace( $pattern, "", $newbody); 
        $newbody = preg_replace("#\\" . $emojiB . "#si",$emojiA , $newbody);
        $sender->EventArguments['Object']->FormatBody = $newbody;
    }
    
    }
    

    feel free to change case and indentation.

    if it doesn't work for you someone else may have a solution.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited November 2015

    :) >:)

    test (same emoji twice above).

    when this emoji >:) is first characters on line thinks its a smile :) when its a >:)

    resulting in an automatic blockquote and a smiley.

    edit:

    an emoji bug in 2.2 as well as on this forum

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • xm1xm1 New
    edited November 2015

    @peregrine I do not want to get ride of images, I just want to prevent users from embedding external images.

  • peregrineperegrine MVP
    edited November 2015

    I just want to prevent users from embedding external images.

    exactly what I provided.

    @xm1 sorry, but I think I am wasting my time.

    with the above plugin - users can still upload images, as attachments, and inline images are gone except for emojis - solves the problem.

    and the css provided - answers your other question.

    Did you even try the plugin? to see what it does.

    either you don't understand what you want or I don't :)

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.