Serving images hardcoded in HTML?
-
I’ve noticed this plugin is serving CloudFlare images for my posts and woocommerce products, but any images which are written as URL’s in the html aren’t being replaced with CloudFlare Images. Is this not something the plugin is capable of?
The page I need help with: [log in to see the link]
-
Hi @mrcultivator,
At the moment, only images that get processed via WordPress image functions get replaced. This is done to make the plugin as fast as possible. Have you thought about inserting the image via one of the WordPress functions? Don’t think that having URLs in the theme is a good practice
Best regards,
AntonThe theme I’m using appears to use it’s own functions… but perhaps there is a way to override them… I’ll look into it for sure.
What about ACF images that are loaded based on file URL? Is there any way to serve those using a specific function?I believe, ACF still uses the WordPress functions under the hood, does it not? If you can provide me some steps to replicate, I can test and try to find a fix.
https://www.420.deals/cali-crusher/
All brand logo images on this page are using ACF taxonomy images as variables:$catimage = get_field( ‘square_logo’, $term );
$logoimage = get_field(‘logo_image’, $term);
Like the following:
<img src=”<?php echo($catimage)?>” alt=”Buy <?php echo $page_title;?>” width=”60px” height=”60px”>
And despite these images being uploaded to CloudFlare, they’re not being served at all on any of the pages using this template…-
This reply was modified 3 years, 1 month ago by
MrCultivator.
I have published a beta version that adds ACF integration. Could you please test it out and see if it fixes the issue for you?
https://github.com/av3nger/cf-images/releases/tag/1.2.1-beta.1
Unfortunately it caused a critical error on the site. I’ve had to deactivate it.
What was the error?
I’ll look at my logs now. One moment.
[04-May-2023 23:25:02 UTC] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function bodhi_svgs_dimension_fallback(), 3 passed in /home/customer/www/420.deals/public_html/wp-includes/class-wp-hook.php on line 308 and exactly 4 expected in /home/customer/www/420.deals/public_html/wp-content/plugins/svg-support/functions/attachment.php:311
Seems to be conflict with SVG Support plugin…I deactivated the SVG Support plugin and still got the critical error:
[04-May-2023 23:34:24 UTC] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function WC_Regenerate_Images::maybe_resize_image(), 3 passed in /home/customer/www/420.deals/public_html/wp-includes/class-wp-hook.php on line 308 and exactly 4 expected in /home/customer/www/420.deals/public_html/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php:201 Stack trace: #0 /home/customer/www/420.deals/public_html/wp-includes/class-wp-hook.php(308): WC_Regenerate_Images::maybe_resize_image(Array, 22972, '') #1 /home/customer/www/420.deals/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array) #2 /home/customer/www/420.deals/public_html/wp-content/plugins/cf-images/app/integrations/class-acf.php(51): apply_filters('wp_get_attachme...', Array, 22972, '') #3 /home/customer/www/420.deals/public_html/wp-includes/class-wp-hook.php(308): CF_Images\App\Integrations\ACF->image_field_type_url('https://www.420...', 22972) #4 /home/customer/www/420.deals/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(' in /home/customer/www/420.deals/public_html/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php on line 201-
This reply was modified 3 years, 1 month ago by
MrCultivator.
Sorry for that. Fixed. Re-uploaded the beta version
The critical error has gone, but now it’s serving Array instead of the image URL.
I’ve noticed that SOME images are being served through CloudFlare mind… so it might be partially my php code’s fault…
This works:<img src="<?php echo the_field( 'square_logo', $term ); ?>" alt="<?php echo $term->name; ?>" width="60" height="60">This doesn’t:
$catimage = get_field( 'square_logo', $term ); <img src="<?php echo($catimage)?>" alt="Buy <?php echo $page_title;?>" width="60px" height="60px">Fixed and re-uploaded again
Great work! That appears to be working perfectly. Well done!
-
This reply was modified 3 years, 1 month ago by
The topic ‘Serving images hardcoded in HTML?’ is closed to new replies.