twittercards setImage修正
Showing
1 changed file
with
9 additions
and
7 deletions
... | @@ -45,7 +45,9 @@ class PlgContentTweetcards extends JPlugin | ... | @@ -45,7 +45,9 @@ class PlgContentTweetcards extends JPlugin |
45 | ), | 45 | ), |
46 | $this->setImage( | 46 | $this->setImage( |
47 | $row->images, | 47 | $row->images, |
48 | $row->text | 48 | $row->text, |
49 | $context, | ||
50 | $row->category_alias | ||
49 | ), | 51 | ), |
50 | $this->setMetadesc( | 52 | $this->setMetadesc( |
51 | $row->metadesc, | 53 | $row->metadesc, |
... | @@ -81,16 +83,16 @@ class PlgContentTweetcards extends JPlugin | ... | @@ -81,16 +83,16 @@ class PlgContentTweetcards extends JPlugin |
81 | * | 83 | * |
82 | * @since 0.0.1 | 84 | * @since 0.0.1 |
83 | */ | 85 | */ |
84 | protected function setImage($images, $text) { | 86 | protected function setImage($images, $text, $context, $category_alias) { |
85 | $fullImage = json_decode($images); | 87 | $fullImage = json_decode($images); |
86 | preg_match_all('|<img.*?src=[\'"](.*?)[\'"].*?>|i', $text, $matches); | 88 | preg_match_all('|<img.*?src=[\'"](.*?)[\'"].*?>|i', $text, $matches); |
87 | if ( !empty($fullImage->image_fulltext) ) { | 89 | if ( !empty($fullImage->image_fulltext) ) { |
88 | $image = JURI::base() . $fullImage->image_fulltext; | 90 | $image = JURI::base() . $fullImage->image_fulltext; |
89 | // 本文中の画像の自動選択をOFF | 91 | // 本文中の画像の自動選択をカテゴリ:インフォメーションのみ有効化 |
90 | // } elseif( !empty($matches[ 1 ][ 0 ]) ) { | 92 | } elseif( $category_alias == 'target-info' && $context == 'com_content.article' && !empty($matches[ 1 ][ 0 ]) ) { |
91 | // $image = $matches[ 1 ][ 0 ]; | 93 | $image = $matches[ 1 ][ 0 ]; |
92 | // $image = str_replace(JURI::base(), '', $image); | 94 | $image = str_replace(JURI::base(), '', $image); |
93 | // $image = JURI::base() . $image; | 95 | $image = JURI::base() . $image; |
94 | } else { | 96 | } else { |
95 | $image = ''; | 97 | $image = ''; |
96 | } | 98 | } | ... | ... |
-
Please register or sign in to post a comment