Jump to content

Better Titles on Links


Geramy92

Recommended Posts

Hello,

I was thinking about changing the plugin for autolink titles. My problem is that I don't find a way to place a really nice solution. Why: Simply because I have to replace the autolink plugin of the ckeditor and need a hook that replaces the complete validateLink() Function.

To Change it that it will place the title instead of the url (which is better) it needs only to change some lines:

(Line 471)

if (response.title) {
  link.setText(response.title);
}

 

And in the \applications\core\modules\front\system\editor.php

In Line 160

$response = \IPS\Http\Url::external( $title )->request()->get();              	
	              
preg_match( '/^([^;]+)(?:;\s*charset=(.*))?/im', $response->httpHeaders['Content-Type'], $matches );
if(isset($matches[1]) && $matches[1] == 'text/html' && preg_match('#<title[^>]*>(.*)</title>#siU', $response->content, $match)) {
	if(isset($matches[2]) && \strtolower($matches[2]) != 'utf-8' && function_exists('mb_convert_encoding')) {
		$match[1] = @mb_convert_encoding($match[1], 'utf-8', $matches[2]);
	}
	unset($response);
	$title = $match[1];
}

 

The last thing could be done also by a hook if we get the ability to have there some kind of return instead of directly calling (and of course the js change above)

\IPS\Output::i()->json( $result );

greetings
Geramy92

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...