Closed mauryaratan closed 2 years ago
After analyzing the image import logic I believe that the file structure (template-11-120-hash) is not possible due to the following reasons
The post id is generated after the media is uploaded.
In Elementor class Import_Images: Elementor wp_upload_bits call occur before attachment post creation
The same problem is applicable for our plugin class Import_Images: Analog wp_upload_bits occur before attachment post creation
The hash generation also mapped after the creation of Image and Image's post i.e. WP attachment post
Elementor source link: Image hash mapping to the attachment post
Analog source link: Image hash mapping to the attachment post
While exploring the three AJAX calls (Templates, Style Kits, and Blocks Imports) found that all these three commonly passing the following parameters in the request
so shall we make use of these values and suffix it like this mediaName(id)(site_id)_hash(title).jpg or else as we noted both in Elementor & Analog the hash generated using the remote URL so shall we make naming convention in remote URL itself to make media's name unique.
@mauryaratan kindly share your thoughts
Hey @gvgvgvijayan,
Thanks for looking into it.
Here's what my initial thoughts are:
template-11-120-hash
is a folder name.template-11-120-hash
, for blocks block-11-120-hash
. Parameters should be the same as suggested originally, siteID
, postID
, and a unique hash. @mauryaratan I will check that.
_elementor_source_image_hash
or _analog_image_hash
This is no longer a requirement, let's close this!
Currently, any images imported from templates/blocks are directly uploaded in the media library. Let's change that so all images are categorized with template ids inside a designated folder. Here's what it may look like:
uploads/style-kits
template-11-120-hash
template-12-240-hash
Where
11
is site ID,120
is Post ID, andhash
is a unique generated string during import.This makes cleanup easier if/when users decide to remove Style Kits plugin and also gives them an idea of what came from our plugin.