WordPress.org

Ready to get started?Download WordPress

Forums

PHP in images tags (3 posts)

  1. cron
    Member
    Posted 9 years ago #

    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?

  2. Lorelle
    Member
    Posted 9 years ago #

    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.

  3. cron
    Member
    Posted 9 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.