Support » Plugins » Hacks » How to insert some code BEFORE 1st image in every post?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Can you be more specific what you want to insert? And how is the image being inserted?

    I would like to insert this code:

    <?php if ($is_hd) { ?>

    <fieldset id=”hdswitch”>
    <span>Choose:</span> <span><label for=”px1024″><input id=”px1024″ type=”radio” name=”blogwidth” value=”1024″ checked=”checked” /> 1024px</label></span>

    <span><label for=”px1280″><input id=”px1280″ type=”radio” name=”blogwidth” value=”1280″ /> 1280px</label></span>
    </fieldset>

    <?php } ?>

    An Example:

    http://www.theatlantic.com/infocus/2012/04/space-shuttle-discoverys-final-flight/100281/

    > And how is the image being inserted?

    I have a lot of images in posts:
    <img style=”padding: 0px; display: inline; title=”title” border=”0″ alt=”alt” src=”http://site.com/content/2012/04/post_name/25.jpg” width=”…” height=”…” />

    So you want to do it on the single.php, or in index.php?

    I’m just curious why you can’t edit the templates.

    I want to do it on the single.php.
    But it is not possible to insert automatically the code above first image into single.php like this:
    http://dl.dropbox.com/u/24525697/10.jpg

    I suppose I should insert some hack into functions.php. Somesing like popular “How to: Get the first image from the post”

    Certainly there are ways to parse the 1st attached image, and you could include your code in that function, but personally, I’d use the featured image for that and insert the code above the call for the featured image in single.php.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to insert some code BEFORE 1st image in every post?’ is closed to new replies.