0
{exp:ce_img:single
    allow_scale_larger="yes"
    crop="yes|center,center|0,0|yes"
    filter="auto_sharpen"
    hash_filename="yes"
    height="{embed:height}"
    parse="inward"
    src="{exp:stash:get name='default-profile-image'}"
    url_only="yes"
    width="{embed:width}"
}

It seems like CE Image is ignoring the embed values for height and width. I've verified that the calling template is indeed passing the correct values and that the template that this CE Image tag is in can access those values. When I hard code numeric values for height and width, it works as expected. The problem only seems to occur when I try to use the embed variables.

I already have parse="inward", which was needed for the Stash variable to work. Any ideas what is wrong?

UPDATE 1:

Since it appears that the Stash variable works, I decided to try setting the embed variable to a Stash variable:

{exp:stash:set parse_conditionals="yes" parse_tags="yes"}
    {stash:height}{embed:height}{/stash:height}
{/exp:stash:set}
{exp:stash:set parse_conditionals="yes" parse_tags="yes"}
    {stash:width}{embed:width}{/stash:width}
{/exp:stash:set}

Then I used the Stash variable as the parameter value in CE Image:

{exp:config_variables:get name='no_protocol_site_url'}{exp:ce_img:single
    allow_scale_larger="yes"
    crop="yes|center,center|0,0|yes"
    filter="auto_sharpen"
    hash_filename="yes"
    height="{exp:stash:get name='height'}"
    parse="inward"
    src="{exp:stash:get name='default-profile-image'}"
    url_only="yes"
    width="{exp:stash:get name='width'}"
}

It still seems as if CE Image is ignoring the parameter values for height and width.

Within the template with the CE Image tag, I see the proper values being outputted by these:

<h1>{embed:width}</h1>
<h2>{exp:stash:get name='width'}</h2>

UPDATE 2:

I enabled template debugger and noticed this:

Embed Variables (Keys): author_id|width|height
Embed Variables (Values): 175|{img_base_dimension_md}|{img_base_dimension_md}

{img_base_dimension_md} and {img_base_dimension_md} are snippets and are being passed from the embed:

{embed='test/get-image' author_id='175' width='{img_base_dimension_md}' height='{img_base_dimension_md}'}

If the values are just the string interpretation of the snippets, then I don't see how I am getting the snippet values when I output them in the <h1>.

2
  • Hi! Why, if the dimensions values are snippets, you don't just use them? Why passing them as embed variables?
    – Sobral
    Jun 17 '14 at 20:31
  • 1
    Because I have multiple snippets with various values. The template that does the embedding decides which snippet to pass. Jun 17 '14 at 20:45
0

The EE parser parses embed variables long before exp tags are parsed (see the EE parser rendering stages), so if the CE Image tag is in an actual embed template, then using the embed variables shouldn't be an issue. Are you including the embed with the normal {embed=''} syntax?

If you enable the template debugger, you can search through the output and see exactly what is being passed into the CE Image tag by the EE parser. Once you know what is actually being passed in, it is easier to work backwards and see where setting the variables is going wrong.

3
  • Did you read my edits? Don't the outputted <h1> and <h2> indicate that I am passing the embed variables correctly? Jun 17 '14 at 20:15
  • I've enabled template debugger and noticed something strange. Please see Update 2. Jun 17 '14 at 20:24
  • Snippets are parsed way before embeds are, so they should be passing in values, not un-parsed variables. Are you using an add-on to create your snippets, or are you creating them in the native control panel interface? Are you using an add-on to include the template that may be messing with the parse order? In the template debugger, do you see that the un-parsed snippet variables are being passed into the CE Image tag too then? Jun 18 '14 at 4:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.