• Resolved George Moureau

    (@georgepiccexcellencecom)


    I have to present a png image (a certificate) for a training program. Pre-WordPress I modified the header of the calling program (it called a php program) with the below code?

    <?php
    $im = imagecreatefrompng(“test.png”);

    header(‘Content-Type: image/png’);
    ?>

    Why won’t it work in wordpress?

    George

Viewing 7 replies - 1 through 7 (of 7 total)
  • Why not just insert the image on a Post or Page?

    Thread Starter George Moureau

    (@georgepiccexcellencecom)

    It’s a certificate from an online training program. It doesn’t print if they don’t pass the course. Have to determine if they pass or not…The certificate is printed with their name and their score on it.

    Then I’d suggest that you look at some sort of restricted download plugin. You cannot use header('Content-Type: image/png'); in a WP page or template file.

    Thread Starter George Moureau

    (@georgepiccexcellencecom)

    what is a restricted download plugin? These aren’t WP pages or templates. They simply are accessed through a wp login front end. They are linked through a wp account info page. Once there, wp has been left behind….

    Can you post a link to this page?

    Thread Starter George Moureau

    (@georgepiccexcellencecom)

    https://www.piccexcellence.com. email me at [email address moderated – this forum does not provide support via email] . I don’t want to pass login info on the forum. I really need to figure out how to get around this. It’s a cornerstone to our site..

    thanks,
    George

    Thread Starter George Moureau

    (@georgepiccexcellencecom)

    Ok, I figured it out. I’ve had the output buffer running (ob_start()) in the header.php of my theme. I added ob_clean() to the top of the certificate.php file which generates the png image of the certificate. That fixed it. FYI: you can use header within wp templates, you just have to turn on output buffering.

    George

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Why won't php header(Content-type: 'image/png') work?’ is closed to new replies.