wp_get_attachment_image_srcset returns false
-
Hi,
I’ve noticed that the wp_get_attachment_image_srcset() function returns null when uploaded file has .svg extension. I know that your plugin only allows to upload SVG to WP library and shows thumbnail but maybe you have any idea about it? ??On my website user can upload a separate file for desktop view and a separate file for mobile view. Any format is allowed (jpg/png/svg). My code:
<?php $image_desktop_id = get_field('image_desktop_id'); $image_mobile_id = get_field('image_mobile_id'); $image_default_src = wp_get_attachment_image_src($image_desktop_id, 'full'); ?> <picture> <source media="(max-width: 750px)" srcset="<?php echo wp_get_attachment_image_srcset($image_mobile_id); ?>"> <source media="(min-width: 751px)" srcset="<?php echo wp_get_attachment_image_srcset($image_desktop_id); ?>"> <img src="<?php echo $image_default_src[0]; ?>" srcset="<?php echo wp_get_attachment_image_srcset($image_desktop_id); ?>"> </picture>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘wp_get_attachment_image_srcset returns false’ is closed to new replies.