Skip to content

Instantly share code, notes, and snippets.

@jgrahamc
Last active June 18, 2020 09:38
Show Gist options
  • Select an option

  • Save jgrahamc/df91229381366105c7ff0f88c8c38485 to your computer and use it in GitHub Desktop.

Select an option

Save jgrahamc/df91229381366105c7ff0f88c8c38485 to your computer and use it in GitHub Desktop.

Revisions

  1. jgrahamc revised this gist May 13, 2016. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion index.php
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,7 @@ function ccbysa($imagehtml, $sourceuri, $owneruri, $ownername) {
    <br/>
    <small><a href="https://creativecommons.org/licenses/by-sa/2.0/">CC BY-SA</a>
    <a href="{$sourceuri}">image</a> by <a href="{$owneruri}">{$ownername}</a>
    <br/>
    HTML;
    }

    @@ -15,11 +16,12 @@ function ccbynd($imagehtml, $sourceuri, $owneruri, $ownername) {
    <br/>
    <small><a href="https://creativecommons.org/licenses/by-nd/2.0/">CC BY-ND</a>
    <a href="{$sourceuri}">image</a> by <a href="{$owneruri}">{$ownername}</a>
    <br/>
    HTML;
    }

    function pushImage($uri) {
    header("Link: <{$uri}>; rel=preload;", false);
    header("Link: <{$uri}>; rel=preload; as=image", false);

    return <<<HTML
    <img src="{$uri}">
  2. jgrahamc created this gist May 13, 2016.
    49 changes: 49 additions & 0 deletions index.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    <?php

    function ccbysa($imagehtml, $sourceuri, $owneruri, $ownername) {
    return <<<HTML
    {$imagehtml}
    <br/>
    <small><a href="https://creativecommons.org/licenses/by-sa/2.0/">CC BY-SA</a>
    <a href="{$sourceuri}">image</a> by <a href="{$owneruri}">{$ownername}</a>
    HTML;
    }

    function ccbynd($imagehtml, $sourceuri, $owneruri, $ownername) {
    return <<<HTML
    {$imagehtml}
    <br/>
    <small><a href="https://creativecommons.org/licenses/by-nd/2.0/">CC BY-ND</a>
    <a href="{$sourceuri}">image</a> by <a href="{$owneruri}">{$ownername}</a>
    HTML;
    }

    function pushImage($uri) {
    header("Link: <{$uri}>; rel=preload;", false);

    return <<<HTML
    <img src="{$uri}">
    HTML;
    }

    $image1 = pushImage("/images/drucken.jpg");
    $image2 = pushImage("/images/empire.jpg");

    ?>

    <html>
    <head><title>PHP Server Push</title></head>
    <body>

    <h1>PHP Server Push</h1>

    <?php
    echo ccbysa($image1, "https://bit.ly/1Wu5bYx",
    "https://www.flickr.com/photos/hiperactivo/", "Javier Candeira");

    echo ccbynd($image2, "https://bit.ly/24PHue3",
    "https://www.flickr.com/photos/bobsfever/", "Robert McGoldrick");
    ?>

    </body>
    </html>