fix WSP-65

This commit is contained in:
Filip Penkava
2017-03-15 15:33:39 +01:00
parent 78603128a5
commit ddd44a9f47
2 changed files with 12 additions and 2 deletions

View File

@@ -157,7 +157,16 @@ if ($obj['type'] == 'text') {
/* save featured media */
if ($obj['associations']['featuremedia'] && $obj['associations']['featuremedia']['type'] == 'picture') {
saveAttachment($obj['associations']['featuremedia'], $post_ID);
$filenameQ = explode("/", $obj['associations']['featuremedia']['renditions']['original']['media']);
$filename = $filenameQ[count($filenameQ) - 1];
$fileExist = $wpdb->get_row("SELECT meta_id, post_id FROM " . $wpdb->prefix . "postmeta WHERE meta_key = '_wp_attached_file' AND meta_value LIKE '%" . wp_strip_all_tags($filename) . "'");
if ($fileExist) {
set_post_thumbnail($post_ID, $fileExist->post_id);
} else {
saveAttachment($obj['associations']['featuremedia'], $post_ID);
}
}
} elseif ($obj['pubstatus'] == 'canceled') {
/* remove article */