• Resolved manloveebooks

    (@manloveebooks)


    I’m playing with the attachment page (image.php in this case) and managed to get the image (with link to full size) and the description to show (with the_content() ) example page: https://www.shamelessreading.com/romance-ebook-erotica-blog/bound-by-your-touch/attachment/1416592636/

    But I swear I used to be able to use HTML in the description text and it would show up as working HTML and not the html written out. ?? I’m not sure what I did, but now it’s like this. Any suggestions? Code for said section of image.php page as it stands, below:

    ?<?php get_header(); ?>
    	<div id="content">
    	<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
    			<div class="post" id="post-<?php the_ID(); ?>">
    				<h2><?php the_title(); ?></h2>
    
    				<div class="entry">
    					<?php if (wp_attachment_is_image($post->id)) {
    				$att_image = wp_get_attachment_image_src( $post->id, "medium");
    				?>
    				<p class="attachment">
    					<a href="<?php echo wp_get_attachment_url($post->id); ?>" title="<?php the_title(); ?>">
    					<img src="<?php echo $att_image[0];?>" width="<?php echo $att_image[1];?>" height="<?php echo $att_image[2];?>"  class="attachment-medium" alt="<?php $post->post_excerpt; ?>" />
    					</a>
    
    				</p>
    <?php the_content() ?>
    				<?php } ?>
    				</div>
    
    			</div>
Viewing 7 replies - 1 through 7 (of 7 total)
  • If you go get it working, I’d love to see the solution. Thus far, all my experiments suggest that WP strips out any markup. Maybe using the same filters as it applies to the_excerpt()?

    Thread Starter manloveebooks

    (@manloveebooks)

    It’s really annoying! I was playing around w/ themes, and when I returned to this one, it got all crapped out ?? But I swear I saw it doing this in one of the themes I played with. Just can’t remember which one. ??

    Thread Starter manloveebooks

    (@manloveebooks)

    Weirdness. It’s working now. ??
    And for some reason, when I went back to the description text, at some point in the process, something had turned all the < type characters into &123; type characters.

    Hmmm. I went back and edited it and it’s okay for now. Will have to figure out where along the line it’s screwing w/ the tags.

    Thread Starter manloveebooks

    (@manloveebooks)

    Fuuuuudge, it started doing it again. WTF. ??

    Thread Starter manloveebooks

    (@manloveebooks)

    Okay… seems to be working. I can’t seem to stop wordpress from making the description all funky, but in the code, if I replace
    the_content();

    with

    <?php $content=get_the_content();
    echo $content;?>

    It seems to retranslate the funky characters back into proper HTML. I tracked down that workaround after some poking around, w/ the complaint/warning that get_the_content() doesn’t strip out the html tags. But I guess it… IDK. It works now. *throws hands up in air*

    Thread Starter manloveebooks

    (@manloveebooks)

    ETA: I noticed that if I go back in and retweak the image’s description text after the first time, it goes back to all weird. At that point, I have to delete and start over. But as long as I don’t edit bits of the already “special” description, it sticks.

    For now.

    That’s what I’ve noted too. Since the initial markup is retained (not removed as I incorrectly said earlier), it would seem that a filter is being applied when the description is re-saved and the markup ends up being encoded. Which sounds like a bug in the Edit Media scripts. Wonder if there’s anything about this in Trac?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘html in image description on attachment page?’ is closed to new replies.