• Resolved GeddeDev

    (@ggedde)


    I am needing to do this programmatically and was curious if you have any documentation to your code as to how I can do this with code instead of requiring my clients to do this through the Admin Panel.

    If you don’t have documentation for this can you share some code snippets on how to do this or point me to your code where it is being done.

    I know do to upload images and attach them with code already using WP best practices so I don’t need the a-z tutorial. Just how to manage the replacement part. Thanks.

Viewing 1 replies (of 1 total)
  • Plugin Support Gerard Blanco

    (@sixaxis)

    Hi @ggedde,

    In views/upload.php you can find the script that runs after a file has been uploaded. The script does a lot of checks and prepares the replacer class for doing its job. You can find these functions:

    $replacer = new Replacer($post_id);
    $replacer->setMode(\EnableMediaReplace\Replacer::MODE_REPLACE);
    $replacer->setTimeMode($timestamp_replace, $datetime);
    
    [optionally] $result = $replacer->setNewTargetLocation($new_location_dir);
    
    $result = $replacer->replaceWith($_FILES["userfile"]["tmp_name"], $new_filename);

    Cheers,

Viewing 1 replies (of 1 total)

The topic ‘How to use this programmatically’ is closed to new replies.