-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance/side load images #57
Conversation
includes/Services/SiteGenService.php
Outdated
* | ||
* @param array $active_homepage The active homepage data, including block grammar and image URLs. | ||
*/ | ||
public static function sideload_and_replace( $active_homepage ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this function generic in order to use it in the future for almost all pages, something like sideload_images_and_replace_grammar ( $page_data )
just a recommendation.
includes/Services/SiteGenService.php
Outdated
// Upload the images in the 'generatedImages' array to WordPress media library. | ||
$uploaded_image_urls = self::upload_images_to_wp_media_library( $generated_images ); | ||
|
||
$url_mapping = array_combine( $generated_images, $uploaded_image_urls ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would the mapping work if say one of the URLs was corrupt or was some link that was not valid say out of 4 images the 3rd one won't now the mapping be:
1 - 1
2 - 2
3 - 4
4 - null
Maybe we can return the array in the upload_images_to_wp_media_library
func
It will be a func that takes an array of links and returns a map of old_links -> new_links?
includes/Services/SiteGenService.php
Outdated
// Update the content with new image URLs. | ||
$active_homepage['content'] = $content; | ||
|
||
$data = FlowService::read_data_from_wp_option( false ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering what if we did something like on Line 482:
'content' => $data['content'],
we will just wrap it like
$content = sideload_images_and_replace_grammar($data['content'], $data['generatedImages'])
'content' => $data['content'],
Basically, I want to just remove the read flow and update flow db call, and make it a bit faster as idk if it will be used later if we save it back in flowData.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will replace for all the images right? at this point we plan to replace the one which is active.
refactored Co-authored-by: Allen Benny <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks Good
No description provided.