WordPress.org

Support

Support » How-To and Troubleshooting » PHP in images tags

PHP in images tags

  • I hav the eZstatic plugin installed. This lets be use php in posts. Hoever I have a problem. Whenever I try to use php in an image tag it does not work. WordPress automaticly escapes the > of the php so it does not work.

    Example:

    <img src=”http://www.example.com/graph.php?startdate=< ?php
    $ts = time();
    $today = date( “Y-m-d”, $ts );
    echo $today;
    ?>&enddate=< ?php
    $ts = time();
    $today = date( “Y-m-d”, $ts );
    $one_week = 7 * 24 * 60 * 60;
    $one_week_ago = date( “Y-m-d”, ( $ts – $one_week ) );
    echo $one_week_ago;
    ?>”>

    WordPress automaticly changes this to:

    <img src=”http://www.example.com/graph.php?startdate=< ?php
    $ts = time();
    $today = date( “Y-m-d”, $ts );
    echo $today;
    ?/>&enddate=< ?php
    $ts = time();
    $today = date( “Y-m-d”, $ts );
    $one_week = 7 * 24 * 60 * 60;
    $one_week_ago = date( “Y-m-d”, ( $ts – $one_week ) );
    echo $one_week_ago;
    ?/>”>

    (puts the /s in after the PHP)

    Any sugestions?

Viewing 2 replies - 1 through 2 (of 2 total)
  • I don’t know if this is your issue, but put the /> in your image code because it is supposed to be there, and maybe WP will skip it. It is standards XHMTL to have a self closing slash on a non-closing tag.

    Also, consider making this a php call out rather than putting the PHP code in every image tag. That will also solve the problem.

    Thanks for the help. I am used to HTML not XHTML so i did not know to put the backslash in. Thanks alot.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP in images tags’ is closed to new replies.
Skip to toolbar