Skip to content

Commit

Permalink
Merge pull request #2 from Programmer095/fix/image-update-control
Browse files Browse the repository at this point in the history
Ensure images/files are only downloaded when they're set to be imported
  • Loading branch information
Programmer095 authored Oct 14, 2022
2 parents e864ca5 + 607fd53 commit 1a6f0f0
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions rapid-addon.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ function import($importData, $parsedData) {

$import_options = $importData['import']['options'][$this->slug];

// Contains all of the import options, not just add-on specific ones
$all_import_options = $importData['import'];

// echo "<pre>";
// print_r($import_options);
// echo "</pre>";
Expand All @@ -341,43 +344,43 @@ function import($importData, $parsedData) {

case 'image':

// import the specified image, then set the value of the field to the image ID in the media library
if ( $this->can_update_meta( $field_params['slug'], $all_import_options ) ) {

// import the specified image, then set the value of the field to the image ID in the media library

$image_url_or_path = $parsedData[$field_slug][$index];
$image_url_or_path = $parsedData[$field_slug][$index];

if ( ! array_key_exists( $field_slug, $import_options['download_image'] ) ) {
continue 2;
}
$download = $import_options['download_image'][$field_slug];

$download = $import_options['download_image'][$field_slug];
$uploaded_image = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "images", true, $importData['articleData']);

$uploaded_image = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "images", true, $importData['articleData']);
$data[$field_slug] = array(
"attachment_id" => $uploaded_image,
"image_url_or_path" => $image_url_or_path,
"download" => $download
);

$data[$field_slug] = array(
"attachment_id" => $uploaded_image,
"image_url_or_path" => $image_url_or_path,
"download" => $download
);
}

break;

case 'file':

$image_url_or_path = $parsedData[$field_slug][$index];
if ( $this->can_update_meta( $field_params['slug'], $all_import_options ) ) {

if ( ! array_key_exists( $field_slug, $import_options['download_image'] ) ) {
continue 2;
}
$image_url_or_path = $parsedData[$field_slug][$index];

$download = $import_options['download_image'][$field_slug];

$download = $import_options['download_image'][$field_slug];
$uploaded_file = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "files", true, $importData['articleData']);

$uploaded_file = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "files", true, $importData['articleData']);
$data[$field_slug] = array(
"attachment_id" => $uploaded_file,
"image_url_or_path" => $image_url_or_path,
"download" => $download
);

$data[$field_slug] = array(
"attachment_id" => $uploaded_file,
"image_url_or_path" => $image_url_or_path,
"download" => $download
);
}

break;

Expand Down

0 comments on commit 1a6f0f0

Please sign in to comment.