Title: Error when adding additional attributes
Last modified: September 1, 2016

---

# Error when adding additional attributes

 *  Resolved [Aldo](https://wordpress.org/support/users/ab_lu/)
 * (@ab_lu)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/)
 * Hi Stefan
 * We try to add some additional attributes to the img tag:
 *     ```
       'attributes' => array(
                                   'img' => array(
                                         'class'           => 'lazyload img-responsive',
                                         'data-sizes'      => 'auto',
                                         'data-parent-fit' => 'cover'
                                     )
                                   )
       ```
   
 * Unfortunately we get then the following error:
 *     ```
       <b>Warning</b>:  Illegal string offset 'property' in <b>/Volumes/Data/WEB/HTDOCS/site/web/app/plugins/responsify-wp/includes/img.php</b> on line <b>43</b><br />
       <br />
       <b>Warning</b>:  Illegal string offset 'value' in <b>/Volumes/Data/WEB/HTDOCS/site/web/app/plugins/responsify-wp/includes/img.php</b> on line <b>43</b><br />
       <br />
       <b>Warning</b>:  Illegal string offset 'property' in <b>/Volumes/Data/WEB/HTDOCS/site/web/app/plugins/responsify-wp/includes/img.php</b> on line <b>43</b><br />
       <br />
       <b>Warning</b>:  Illegal string offset 'value' in <b>/Volumes/Data/WEB/HTDOCS/site/web/app/plugins/responsify-wp/includes/img.php</b> on line <b>43</b><br />
       ```
   
 * Any idea?
 * [https://wordpress.org/plugins/responsify-wp/](https://wordpress.org/plugins/responsify-wp/)

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/error-when-adding-additional-attributes/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/error-when-adding-additional-attributes/page/2/?output_format=md)

 *  Plugin Author [stefanledin](https://wordpress.org/support/users/stefanledin/)
 * (@stefanledin)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544806)
 * Remove the `img` array. Like this:
 *     ```
       'attributes' => array(
           'class'           => 'lazyload img-responsive',
           'data-sizes'      => 'auto',
           'data-parent-fit' => 'cover'
       )
       ```
   
 *  Thread Starter [Aldo](https://wordpress.org/support/users/ab_lu/)
 * (@ab_lu)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544808)
 * Still the same.
 *  Plugin Author [stefanledin](https://wordpress.org/support/users/stefanledin/)
 * (@stefanledin)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544810)
 * With the other thread in mind, are you doing something special with media queries?
   The error occurs when the sizes attribute is created.
 *  Thread Starter [Aldo](https://wordpress.org/support/users/ab_lu/)
 * (@ab_lu)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544812)
 * No, nothing special. This is the complete attributes array:
 *     ```
       $rwp_attributes = array(
                       'sizes' => array( 'image-xs', 'image-sm', 'image-md', 'image-lg', 'image-xlg' ),
                       'media_queries' => array(
                                     'image-xs' => 'max-width: 320px',
                                     'image-sm' => 'min-width: 321px',
                                     'image-md' => 'min-width: 770px',
                                     'image-lg' => 'min-width: 1000px',
                                     'image-xlg' => 'min-width: 1540px'
                         ),
                         'retina' => true,
                         'attributes' => array(
                                         'class'           => 'lazyload img-responsive',
                                         'data-sizes'      => 'auto',
                                         'data-parent-fit' => 'cover'
                                     )
   
                       );
       ```
   
 *  Thread Starter [Aldo](https://wordpress.org/support/users/ab_lu/)
 * (@ab_lu)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544814)
 * It only happens using `rwp_img`.
    With `rwp_picture` the output is fine. But 
   I need to use `rwp_img`
 *  Plugin Author [stefanledin](https://wordpress.org/support/users/stefanledin/)
 * (@stefanledin)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544834)
 * Oh, now I see. Media queries are written like that for the picture element. For`
   img`, you’re really only changing the `sizes` attribute, which you can set in
   the attributes array.
 *     ```
       $rwp_attributes = array(
       	'sizes' => array( 'thumbnail', 'medium', 'large' ),
       	'retina' => true,
       	'attributes' => array(
       		'class'           => 'lazyload img-responsive',
       		'data-sizes'      => 'auto',
       		'data-parent-fit' => 'cover',
       		'sizes' => '(min-width: 1540px) [image-lg-width]px, (min-width: 1000px) [image-lg-width]px, (min-width: 770px) [image-md-width]px, (min-width: 321px) [image-sm-width]px, [image-xs-width]px'
       	)
       );
       ```
   
 * I know it’s hard to understand the code above, but I think that this “formula”
   would do the trick. You just have to insert the sizes of your custom image sizes.
 *  Thread Starter [Aldo](https://wordpress.org/support/users/ab_lu/)
 * (@ab_lu)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544839)
 * I still get the same error.
    BTW: Do I not need to add the retina sizes in the‘
   sizes’ paramter?
 *  Plugin Author [stefanledin](https://wordpress.org/support/users/stefanledin/)
 * (@stefanledin)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544853)
 * Really? You don’t have the old code in some other place?
 * Yeah you just have to add the image sizes that you wanna use. `img` just want
   to have a bunch of different images to choose from, it doesn’t care if it’s “
   retina” or not. `picture` however needs to have the original and retina image
   grouped together in the same `<source>` tag.
 *  Thread Starter [Aldo](https://wordpress.org/support/users/ab_lu/)
 * (@ab_lu)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544855)
 * No nowhere else.
    And the warnings are returned exactly where the image markup
   is rendered.
 *  Plugin Author [stefanledin](https://wordpress.org/support/users/stefanledin/)
 * (@stefanledin)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544860)
 * Haha, of course they are. Why would anything be easy? 😉
 * Okey, back to the drawing board. Can I get the code for your custom image sizes
   and dimensions for the built in sizes so I can recreate the scenario?
    Twenty
   fifteen was the theme, right?
 *  Thread Starter [Aldo](https://wordpress.org/support/users/ab_lu/)
 * (@ab_lu)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544861)
 * Her you go 🙂
 *     ```
       add_image_size( 'image-xs', 385, 9999 );
       add_image_size( 'image-xs@2x', 770, 9999 );
   
       add_image_size( 'image-sm', 500, 9999 );
       add_image_size( 'image-sm@2x', 1000, 9999 );
   
       add_image_size( 'image-md', 770, 9999 );
       add_image_size( 'image-md@2x', 1540, 9999 );
   
       add_image_size( 'image-lg', 1000, 9999 );
       add_image_size( 'image-lg@2x', 2000, 9999 );
   
       add_image_size( 'image-xlg', 1540, 9999 );
       add_image_size( 'image-xlg@2x', 3080, 9999 );
       ```
   
 * Regarding the theme, it doesn’t matter a tried with some standard WP themes and
   my own and I get everywhere the same warnings.
 *  Plugin Author [stefanledin](https://wordpress.org/support/users/stefanledin/)
 * (@stefanledin)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544862)
 * Thanks!
    It works like a charm for me… I tested on a clean installation with 
   twenty fifteen and standard RWP settings, beside of the `picture` element as 
   markup pattern.
 * I uploaded an image and placed the following code above the loop in `index.php`:
 *     ```
       <?php
       echo rwp_img(6, array(
           'sizes' => array( 'image-xs', 'image-sm', 'image-md', 'image-lg', 'image-xlg' ),
           'retina' => true,
           'attributes' => array(
               'class'           => 'lazyload img-responsive',
               'data-sizes'      => 'auto',
               'data-parent-fit' => 'cover',
               'sizes' => '(min-width: 1540px) 1540px, (min-width: 1000px) 1000px, (min-width: 770px) 770px, (min-width: 321px) 500px, 385px'
   
           )
       ));
       ?>
       ```
   
 * Works perfectly!
 * What happens if you remove the settings array? Any errors then? And if you then
   add one option at the time into the settings array?
 * You could also add `var_dump($mq);` before line 43 in `responsify-wp/includes/
   img.php` and see what happens.
    It should look like this then:
 *     ```
       if ( isset($images[$i]['media_query']) ) {
           $mq = $images[$i]['media_query'];
           $attribute[] = '('.$mq['property'].': '.$mq['value'].') '.$images[$i]['width'].'px';
       } else {
           $attribute[] = $images[$i]['width'].'px';
       }
       ```
   
 *  Thread Starter [Aldo](https://wordpress.org/support/users/ab_lu/)
 * (@ab_lu)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544885)
 * Hi Stefan
 * I found the issue.
    Had the media_queries array still present. removed it and
   all okay. But one remaining issue.
 * The images in the srcset are all returned twice. Here the markup:
 * `<img srcset="/app/uploads/2016/04/Webseite_Mood-385x261.jpg 385w, /app/uploads/
   2016/04/Webseite_Mood-770x522.jpg 770w, /app/uploads/2016/04/Webseite_Mood-500x339.
   jpg 500w, /app/uploads/2016/04/Webseite_Mood-1000x678.jpg 1000w, /app/uploads/
   2016/04/Webseite_Mood-770x522.jpg 770w, /app/uploads/2016/04/Webseite_Mood-1540x1045.
   jpg 1540w, /app/uploads/2016/04/Webseite_Mood-1000x678.jpg 1000w, /app/uploads/
   2016/04/Webseite_Mood-2000x1357.jpg 2000w, /app/uploads/2016/04/Webseite_Mood-
   1540x1045.jpg 1540w" sizes="(min-width: 1540px) 1540px, (min-width: 1000px) 1000px,(
   min-width: 770px) 770px, (min-width: 321px) 500px, 385px" class="lazyload img-
   responsive" data-sizes="auto" data-parent-fit="cover">`
 * Any idea?
 *  Plugin Author [stefanledin](https://wordpress.org/support/users/stefanledin/)
 * (@stefanledin)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544908)
 * Isn’t it the retina sizes?
 *  Thread Starter [Aldo](https://wordpress.org/support/users/ab_lu/)
 * (@ab_lu)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/#post-7544912)
 * No, if the would have the “@2x” in the filename, not?

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/error-when-adding-additional-attributes/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/error-when-adding-additional-attributes/page/2/?output_format=md)

The topic ‘Error when adding additional attributes’ is closed to new replies.

 * ![](https://ps.w.org/responsify-wp/assets/icon-256x256.png?rev=1209208)
 * [Responsify WP](https://wordpress.org/plugins/responsify-wp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/responsify-wp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/responsify-wp/)
 * [Active Topics](https://wordpress.org/support/plugin/responsify-wp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/responsify-wp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/responsify-wp/reviews/)

 * 19 replies
 * 2 participants
 * Last reply from: [Aldo](https://wordpress.org/support/users/ab_lu/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/error-when-adding-additional-attributes/page/2/#post-7544933)
 * Status: resolved