Skip to content

Parsing issues with @image directive. Fatal Error #42

@christianmagill

Description

@christianmagill

I've run into parsing issues with the @image directive.

Case 1:

When using the directive as follows:

@image($image_id, 'medium', $alt)

The alt attribute is assigned the literal string "$alt" instead of the variable.

The resulting code ends up being...

<?php echo wp_get_attachment_image(
                $image_id,
                'medium',
                false,
                ['alt' => '$alt']
            ); ?>

Case 2:

When using the directive as follows:

@image($image_id, 'medium', ['alt' => $alt, class='alignright'] )

This one results in a Fatal Error

Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: syntax error, unexpected '','' (T_CONSTANT_ENCAPSED_STRING), expecting ']'

The resulting code is...

<?php echo wp_get_attachment_image(
                $image_id,
                'medium',
                false,
                ['alt' => $alt','class' => 'alignright']
            ); ?>

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions