social 0.12: Smiley-blacklist, re-use timeline image
This commit is contained in:
parent
358e2d8baa
commit
673d61f5e8
2 changed files with 23 additions and 12 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
0.12:
|
||||||
|
* Ignore smileys graphics for og:image
|
||||||
|
* Use entry picture from the timeline theme if set
|
||||||
|
|
||||||
0.11:
|
0.11:
|
||||||
* Re-use description set in the metadesc-plugin
|
* Re-use description set in the metadesc-plugin
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class serendipity_event_social extends serendipity_event {
|
||||||
$propbag->add('description', PLUGIN_EVENT_SOCIAL_DESC);
|
$propbag->add('description', PLUGIN_EVENT_SOCIAL_DESC);
|
||||||
$propbag->add('stackable', false);
|
$propbag->add('stackable', false);
|
||||||
$propbag->add('author', 'onli, Matthias Mees, Thomas Hochstein');
|
$propbag->add('author', 'onli, Matthias Mees, Thomas Hochstein');
|
||||||
$propbag->add('version', '0.11');
|
$propbag->add('version', '0.12');
|
||||||
$propbag->add('requirements', array(
|
$propbag->add('requirements', array(
|
||||||
'serendipity' => '2.0'
|
'serendipity' => '2.0'
|
||||||
));
|
));
|
||||||
|
@ -154,22 +154,29 @@ class serendipity_event_social extends serendipity_event {
|
||||||
# /\s+/: multiple newline and whitespaces
|
# /\s+/: multiple newline and whitespaces
|
||||||
$meta_description = trim(preg_replace('/\s+/', ' ', substr(strip_tags($entry['body']), 0, 200))) . '...';
|
$meta_description = trim(preg_replace('/\s+/', ' ', substr(strip_tags($entry['body']), 0, 200))) . '...';
|
||||||
}
|
}
|
||||||
$meta_description = serendipity_specialchars($meta_description);
|
echo '<meta property="og:description" content="' . serendipity_specialchars($meta_description) . '" />' . "\n";
|
||||||
echo '<meta property="og:description" content="' . $meta_description . '" />' . "\n";
|
|
||||||
echo '<meta property="og:type" content="article" />' . "\n";
|
echo '<meta property="og:type" content="article" />' . "\n";
|
||||||
echo '<meta property="og:site_name" content="' . $serendipity['blogTitle'] . '" />' . "\n";
|
echo '<meta property="og:site_name" content="' . $serendipity['blogTitle'] . '" />' . "\n";
|
||||||
echo '<meta property="og:url" content="'. $blogURL . serendipity_specialchars($_SERVER['REQUEST_URI']) . '" />' . "\n";
|
echo '<meta property="og:url" content="'. $blogURL . serendipity_specialchars($_SERVER['REQUEST_URI']) . '" />' . "\n";
|
||||||
|
|
||||||
$social_image = $blogURL . $this->get_config('social_image', '');
|
$social_image = $this->get_config('social_image', '');
|
||||||
|
if (isset($entry['properties']) && isset($entry['properties']['timeline_image'])) {
|
||||||
|
$social_image = $entry['properties']['timeline_image'];
|
||||||
|
} else {
|
||||||
// This is searching for the first image in an entry to use as facebook article image.
|
// This is searching for the first image in an entry to use as facebook article image.
|
||||||
// A better approach would be to register in the entry editor when an image was added
|
// A better approach would be to register in the entry editor when an image was added
|
||||||
if (preg_match('@<img.*src=["\'](.+)["\']@imsU', $entry['body'] . $entry['extended'], $im)) {
|
if (preg_match_all('@<img.*src=["\'](.+)["\']@imsU', $entry['body'] . $entry['extended'], $images)) {
|
||||||
if (preg_match('/^http/i', $im[1])) {
|
foreach (array_reverse($images[1]) as $im) {
|
||||||
$social_image = $im[1];
|
if (strpos($im, '/emoticons/') === false) {
|
||||||
} else {
|
$social_image = $im;
|
||||||
$social_image = $blogURL . $im[1];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! preg_match('/^http/i', $social_image)) {
|
||||||
|
$social_image = $blogURL . $social_image;
|
||||||
|
}
|
||||||
|
|
||||||
if ($social_image != $blogURL && $social_image != $blogURL . 'none') {
|
if ($social_image != $blogURL && $social_image != $blogURL . 'none') {
|
||||||
echo '<meta property="og:image" content="' . $social_image . '" />' . "\n";
|
echo '<meta property="og:image" content="' . $social_image . '" />' . "\n";
|
||||||
|
|
Loading…
Reference in a new issue