Help with elementor/frontend/section/before_render #28499
Replies: 2 comments
-
UPDATE - found a solution, for anyone who has need of this. This could still use a couple of checks to make sure that 1. Elementor is installed and 2. the site is even using a CDN for images, but it does the job. Also interestingly, the Media Library URLs are correct, so all I'm doing is replacng the incorrect local URL with the real media URL pulled via wp_get_attachment_url() -- makes me think that Elementor needs code similar to this built in to the core. add_filter('elementor/frontend/builder_content_data', function($data, $post_id) {
}, 10, 2); |
Beta Was this translation helpful? Give feedback.
-
We are looking for frontend and backend developers as our teammates for our edtech project [email protected] |
Beta Was this translation helpful? Give feedback.
-
Prerequisites
What problem is your feature request going to solve? Please describe..
Apologies, this belongs in the developer API discussion but Github only offers me this as an option - sorry, very open to help in how to move this!
I'm working with the action hook described here:
https://developers.elementor.com/docs/hooks/render-frontend-elements/#advanced-usage
I can get the values of a section background background image slider with $element->get_settings('background_slideshow_gallery'), but I can't find documentation on how to change them before the html renders on the front end -- something like $element->set_settings('background_slideshow_gallery', $array) ?
Thanks!
David
Describe the solution you'd like.
Code example or alternative hooks/filters to change the URLs, or any simpler alternative that accomplishes the same goal.
Describe alternatives you've considered.
I've considered using elementor/frontend/the_content and doing a regex replacement of image URLs, but the remote URLs contain a unique timestamp/version, so it would require a lot of matching file names to media IDs to get the correct URL for each item. Better to fix the individual items before the html is generated if possible I think.
Additional context
For context, basically I'm using an offload media plugin to use images from a Digital Ocean bucket and it also keeps the media library URLs updated to the remote copy. It well works except for this. All of the media library items show the correct remote URL, and even if I loop through the settings using the code above it shows the correct URLs, but if I just dump the $elements array, it shows local values, and on the front end it's definitely local values. I know I must be missing a trick, maybe it has to do with priority in calling the hook, or something else...? Would love to hear any advice or see code snippets to point me in the right direction.
Agreement
Beta Was this translation helpful? Give feedback.
All reactions