fix WSP-65
This commit is contained in:
11
autoload.php
11
autoload.php
@@ -157,7 +157,16 @@ if ($obj['type'] == 'text') {
|
|||||||
|
|
||||||
/* save featured media */
|
/* save featured media */
|
||||||
if ($obj['associations']['featuremedia'] && $obj['associations']['featuremedia']['type'] == 'picture') {
|
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') {
|
} elseif ($obj['pubstatus'] == 'canceled') {
|
||||||
/* remove article */
|
/* remove article */
|
||||||
|
|||||||
3
mvp.php
3
mvp.php
@@ -84,7 +84,8 @@ function generatePassword() {
|
|||||||
|
|
||||||
function saveAttachment($picture, $post_ID) {
|
function saveAttachment($picture, $post_ID) {
|
||||||
$filenameQ = explode("/", $picture['renditions']['original']['media']);
|
$filenameQ = explode("/", $picture['renditions']['original']['media']);
|
||||||
$filename = $filenameQ[1];
|
$filename = $filenameQ[count($filenameQ) - 1];
|
||||||
|
|
||||||
saveFile($picture['renditions']['original']['href'], wp_upload_dir()['path'] . "/" . $filename);
|
saveFile($picture['renditions']['original']['href'], wp_upload_dir()['path'] . "/" . $filename);
|
||||||
|
|
||||||
$attachment = array(
|
$attachment = array(
|
||||||
|
|||||||
Reference in New Issue
Block a user