Tagged: custom shortcode
-
AuthorPosts
-
September 21, 2021 at 2:57 pm #1321782
Dear Enfold-Team,
just finished a major site update session including updating to the newest Enfold (4.8.6.2) from something pre 4.5 (I think 4.1) and one major change to the color section functionality seems to have broken some custom code. I already tried various fixes, but wasn’t succesful so far and would greatly appreciate any support and/or pointers on this one!Short version:
Is there a way to get a color section shortcode ([av_section ...]) working again just by supplying the absolute path to an image, as it was in the older Enfold versions?Long version:
I created a custom shortcode (in enfold-child) which outputs a completely styled page via enfold shortcodes. (see examples in private content). This includes a color section with a background image, where the image link is pointing to a uploads folder inside my wordpress directory/uploads but not managed via WP Media (images are uploaded there via FTP).The custom code generated so far this, which worked fine in the old Enfold Version:
[av_section min_height='50' min_height_px='500px' padding='small' shadow='no-border-styling' bottom_border='no-border-styling' bottom_border_diagonal_color='#333333' bottom_border_diagonal_direction='' bottom_border_style='' id='' color='alternate_color' custom_bg='' src='$bg' attach='parallax' position='bottom center' repeat='stretch' video='' video_ratio='16:9' overlay_enable='aviaTBoverlay_enable' overlay_opacity='0.4' overlay_color='#000000' overlay_pattern='' overlay_custom_pattern='' custom_class='pr_customproduct_firstsection']
, where $bg is previously declared as the full image path aka “DOMAIN.de/wp-content/uploads/pianorevolution/cat-bg/something.jpg”.This seems to not work anymore in the new Enfold version, I tried to troubleshoot it and found that the new av section shortcode includes not just a src attribute, but now also the two new attributes “attachment=’1293′ attachment_size=’full’ ” (example). It seems that the attachmend attribute is the ID of the picture to be used and redundant to the specific src image path, but I’m not fully sure. Also I don’t know how to get the ID an image based on its path, especially if it wasn’t uploaded via WP but directly via FTP.
Thanks for any help on this one!
JörgSeptember 23, 2021 at 7:05 am #1321984Hey joerka27,
Thank you for the inquiry.
In the later versions of the theme, after version 4.5, shortcodes outside the builder will no longer work. You have to use the avf_alb_exec_sc_only filter to enable execution of shortcodes that are not within the builder.
function avf_custom_exec_sc_only_mod( $exec_sc_only, $obj_sc, $atts, $content, $shortcodename, $fake ) { return true; } add_filter( 'avf_alb_exec_sc_only', 'avf_custom_exec_sc_only_mod', 10, 6 );
You should also apply an av_uid attribute or parameter to the color section shorcode.
[av_section min_height='75' min_height_pc='25' min_height_px='500px' padding='default' custom_margin='0px' custom_margin_sync='true' color='main_color' background='bg_color' custom_bg='' background_gradient_color1='' background_gradient_color2='' background_gradient_direction='vertical' src='http://site/bg.jpg' attachment='18' attachment_size='full' attach='scroll' position='top left' repeat='no-repeat' video='' video_ratio='16:9' overlay_opacity='0.5' overlay_color='' overlay_pattern='' overlay_custom_pattern='' shadow='no-border-styling' bottom_border='no-border-styling' bottom_border_diagonal_color='#333333' bottom_border_diagonal_direction='' bottom_border_style='' custom_arrow_bg='' id='' custom_class='' template_class='' aria_label='' av_element_hidden_in_editor='0' av_uid='av-ktwgvf7r' sc_version='1.0'][/av_section]
Best regards,
IsmaelSeptember 27, 2021 at 8:07 pm #1322538Hi Ismael,
I added the av_uid attribute to my custom-shortcode php file and your supplied code to my child theme’s function.php and did a full flush of cache + deactivated minify css/js in Enfold -> Performance etc., unfortunately it’s not yet fixing the issue of not showing the two image backgrounds, as you can check on the page link provided in my initial post with an example page (second one).
Do you have another idea what we could try to get it working again?
Are the new attributes “attachment” and “attachment_size” necessary? Because so far I only supply the src one and continue with the attach attribute, which worked in the old Enfold versions.Thanks!
JörgSeptember 29, 2021 at 12:25 pm #1322800Hi,
What you can try to do:
In enfold\config-templatebuilder\avia-shortcodes\section\section.php around line 872 you find:
$atts['src'] = '';
Replace this with:
// $atts['src'] = '';
Best regards,
GünterOctober 1, 2021 at 11:41 am #1323117Hi Günter,
thanks a lot also here, your solution works like a charm!
Same question as in my other thread if this will be updated with the next updates or if I have to replace this manually after every update – one answer will be enough (in my other thread), so this can be closed here :-).Cheers,
JoerkaOctober 1, 2021 at 12:14 pm #1323127Hi,
Thanks for the feedback.
I have added this problem to our dev repo – but there are a few things to consider to stay compatible with sites using the ALB and the attachment parameter.
I cannot promise a solution for the next release – please check the changelog or follow https://kriesi.at/support/topic/enfold-upcoming-fixes/
Have a nice day and enjoy the theme.
I will leave this thread open in case you need more info.
Best regards,
GünterOctober 1, 2021 at 3:07 pm #1323163 -
AuthorPosts
- You must be logged in to reply to this topic.