Permalink
Browse files

Strip Featured Image / allow user setting so that if SIC Em uses a ca…

…ptured image as the post's featured image, it will strip out the img tag remaining in the post.
  • Loading branch information...
radgeek committed Apr 8, 2016
1 parent 60d1bd1 commit 87c0eca492e3d19b351bcbbb1887da9d556d5f6c
Showing with 44 additions and 2 deletions.
  1. +44 −2 SicEm.php
View
@@ -156,6 +156,17 @@ public function display_settings ($page, $box = NULL) {
$sicem_crop_ratio = $page->setting('sicem crop ratio', NULL);
$sicem_resize = $page->setting('sicem resize', NULL);
$stripFeaturedImageSelector = array(
'no' => 'Leave references to the image in the post',
'yes' => 'Strip the image out of the syndicated post content',
);
$sfisParams = array(
'input-name' => 'sicem_strip_featured_image',
'setting-default' => NULL,
'global-setting-default' => 'no',
'default-input-value' => 'default',
);
$stripUncacheableImagesSelector = array(
'no' => 'Leave the image in the post with a hotlink to the original image location',
'yes' => 'Strip the image out of the syndicated post content',
@@ -200,6 +211,16 @@ public function display_settings ($page, $box = NULL) {
<input type="number" id="sicem-default-featured-image" name="sicem_default_featured_image" value="<?php print esc_attr($defaultFeaturedImage); ?>" size="3" />
</td></tr>
<tr><th scope="row"><?php _e('Featured image in post content:'); ?></th>
<td><p style="margin-top: 0px">When SIC 'Em uses an image to set the Featured Image for a syndicated post...</p>
<?php
$page->setting_radio_control(
'sicem strip featured image', 'sicem_strip_featured_image',
$stripFeaturedImageSelector, $sfisParams
);
?>
</td></tr>
<tr><th scope="row"><?php _e('Custom Fields:'); ?></th>
<td><p style="margin-top:0px">When FeedWordPress captures a local copy of a syndicated image, store the local URL in a Custom Field named...</p>
<div><label>Name: <input type="text" name="sicem_custom_field_name" value="<?php print esc_attr($customFieldName); ?>" size="15" placeholder="custom field name" /></label>
@@ -246,7 +267,7 @@ public function display_settings ($page, $box = NULL) {
<?php endforeach; ?>
</ul></li>
</ul></td></tr>
<tr><th scope="row"><?php _e('Uncacheable Images:'); ?></th>
<td><p style="margin-top: 0px">When a filter prevents FeedWordPress from
capturing a local copy of a syndicated image...</p>
@@ -300,6 +321,7 @@ public function save_settings ($params, $page) {
$page->update_setting("sicem ${spacedKey}", $update_to);
endforeach;
$page->update_setting('sicem strip featured image', $params["sicem_strip_featured_image"]);
$page->update_setting('sicem strip uncacheable images', $params["sicem_strip_uncacheable_images"]);
endif;
} /* SicEm::save_settings () */
@@ -313,8 +335,28 @@ public function the_content ($content) {
global $post;
if (function_exists('is_syndicated')) :
if (is_syndicated()) :
if (is_syndicated()) :
$source = get_syndication_feed_object($post->ID);
$sfi = $source->setting('sicem strip featured image', 'sicem_strip_featured_image', 'no');
switch ($sfi) :
case 'yes' :
$thumbId = get_post_thumbnail_id($post->ID);
if (!!$thumbId) :
$feat_img = wp_get_attachment_url($thumbId);
$find_url = preg_quote($feat_img);
$content = preg_replace(
':(<img \s+ [^>]*src=[^>]*)'.$find_url.'([^>]*>):ix',
/*blank it out*/ '',
$content
);
endif;
break;
case 'no' :
default :
// NOOP
endswitch;
$ig = $source->setting('sicem insert gallery', 'sicem_insert_gallery', 'no');
switch ($ig) :
case 'before' :

0 comments on commit 87c0eca

Please sign in to comment.