# Setting srcset block attribute on a source element fails

**URL:** https://forum.pinegrow.com/t/setting-srcset-block-attribute-on-a-source-element-fails/7632
**Category:** WordPress
**Tags:** bug, wordpress
**Created:** [January 15, 2023, 4:32pm UTC](https://forum.pinegrow.com/t/setting-srcset-block-attribute-on-a-source-element-fails/7632 "2023-01-15T16:32:58Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![adamslowe](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/adamslowe/32/4590_2.png) [@adamslowe](https://forum.pinegrow.com/u/adamslowe)
#### Post date: [January 15, 2023, 4:32pm UTC](https://forum.pinegrow.com/t/setting-srcset-block-attribute-on-a-source-element-fails/7632/1 "2023-01-15T16:32:58Z")

</div>

I’m trying to create a block for a site logo that lets me specify an SVG with PNG/JPG fallback, and I’m running into some issues. As soon as I tell it that I want to set my srcset attribute, it writes the following PHP code: (PG Desktop 7.1 — issue is not limited to SVG, it happens with other formats as well)

```auto
srcset="<?php echo PG_Blocks::getImageUrl( $args, <?php echo get_template_directory_uri(); ?>/'svg_logo_src', <?php echo get_template_directory_uri(); ?>/'full' ) ?>"/>

```

instead of

```auto
srcset="<?php echo PG_Blocks::getImageUrl( $args, 'svg_logo_src', 'full' ) ?>"/>

```

Which gives me a lovely error message on the page.

> **Parse error** : syntax error, unexpected token “\<”, expecting “)”

Is there a different/better way for me to do this? (Note: I did have this working at one point by setting the image with a customizer field action, but I’m doing a block theme and want to try to do as much as I can with blocks.)

**Screenshots** :

Tree:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/c/cf33d53d578012ee14edcac27ac5a6d5d13aedc3.png)

Block Attribute (Smart)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/c/ccc8cdf21cceb86da3bf603d2ef8fa43f1148a1a.png)

Block Attribute (Converted to regular with the same results)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/6/62ace0e81e0f6cc00a59a71f268f94e4d38b0204.png)

---

<div class="post-metadata">

### Author: ![madjedo](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@madjedo](https://forum.pinegrow.com/u/madjedo)
#### Post date: [January 15, 2023, 6:10pm UTC](https://forum.pinegrow.com/t/setting-srcset-block-attribute-on-a-source-element-fails/7632/2 "2023-01-15T18:10:28Z")

</div>

I also wanted to use the picture element in a block. But to no avail.

Think i emailed the pinegrow team regarding this. But again, to no avail.

Dont think this is possible currently. If this is a wordpress or pinegrow limiting factor. I dont know.

To no avail.

I skipped it and moved on.

---

<div class="post-metadata">

### Author: ![adamslowe](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/adamslowe/32/4590_2.png) [@adamslowe](https://forum.pinegrow.com/u/adamslowe)
#### Post date: [January 15, 2023, 6:18pm UTC](https://forum.pinegrow.com/t/setting-srcset-block-attribute-on-a-source-element-fails/7632/3 "2023-01-15T18:18:36Z")

</div>

It’s 👉 this 👈 close. I’m hoping it’s something I’m doing wrong or at least an easy fix that can come in the next version.

---

<div class="post-metadata">

### Author: ![adamslowe](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/adamslowe/32/4590_2.png) [@adamslowe](https://forum.pinegrow.com/u/adamslowe)
#### Post date: [May 9, 2023, 4:36am UTC](https://forum.pinegrow.com/t/setting-srcset-block-attribute-on-a-source-element-fails/7632/4 "2023-05-09T04:36:35Z")

</div>

Hey @matjaz, any thoughts on this one? Using SVG is becoming more standard for logos, so I’d love to have a way to pull them from the customizer and display them as a source in a picture element similar to this:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/1/14f460f447621951049798420ec83453879ed433.png)

```auto
<figure class="header__logo-wrapper">
    <a href="#" cms-site-link="home"><picture>
            <source wp-cz-theme-mod="logo_svg" wp-cz-theme-mod-set="attr" wp-cz-theme-mod-set-attr="src" wp-cz-theme-mod-set-get-image wp-cz-theme-mod-set-get-image-size="full" wp-if-get-theme-mod="logo_svg"/>
            <img src="assets/images/logoipsum-logo-6.png" alt="Placeholder" cms-site-logo/> 
        </picture><span class="screen-reader-text">Homepage Link</span></a>
</figure>

```

As I mentioned in an earlier post, I can get pretty close using the Display Theme Mod action, but it chokes when I change the attribute from `src` to `srcset`.

Here it is with the `src` attribute, which doesn’t work in a `source` element.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/a/a7469a9e068c44e5a458f146d0ea2d9fbb391f71.png)

And this is what happens when I change the attribute to `srcset`

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/e/e9381e9eed431fdc658c8cd9983c4d6ded21c3ea.png)

We’d be set if it just changed the attribute without the other bits. Or, maybe I’m missing something?

---

<div class="post-metadata">

### Author: ![matjaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/matjaz/32/5_2.png) [@matjaz](https://forum.pinegrow.com/u/matjaz)
#### Post date: [May 10, 2023, 5:26am UTC](https://forum.pinegrow.com/t/setting-srcset-block-attribute-on-a-source-element-fails/7632/5 "2023-05-10T05:26:59Z")

</div>

Thanks for asking @adamslowe! There was a bug there. Fixed now, will be out in the next update.
