Dinesh Sharma

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: Center Align Featured Images #4390
    Dinesh Sharma
    Customer

      I have now documented it, just in case someone has same requirements.

      Center Align Featured Images in Genesis

      Thanks,

      Dinesh Sharma

      in reply to: Center Align Featured Images #4383
      Dinesh Sharma
      Customer

        @kronos – well I have submitted my request in studiopress community forums also.

        BTW, I have now found a solution by wrapping featured image in a div.
        I had to add DIV in function genesis_do_post_image() { } in post.php as shown below:


        function genesis_do_post_image() {

        if ( ! is_singular() && genesis_get_option( 'content_archive_thumbnail' ) ) {
        $img = genesis_get_image( array( 'format' => 'html', 'size' => genesis_get_option( 'image_size' ), 'attr' => array( 'class' => 'post-image' ) ) );

        if( ! empty( $img ) )
        printf( '<div class="featured-image">%s</div>', get_permalink(), the_title_attribute( 'echo=0' ), $img );
        }
        }

        Following is the CSS:`
        .featured-image {
        text-align: center;
        }

        .featured-image img {
        margin: 0;
        }
        `

        I was able to do it using Genesis Hooks also except I didn’t see post excerpt in first post. So I just added the required code in Genesis itself. But I guess it will get overwritten with Genesis update. Well until then it good for me.

        You can have a look here.
        http://www.dscentral.in/page/2/

        Thanks,

        Dinesh Sharma

        in reply to: Center Align Featured Images #4237
        Dinesh Sharma
        Customer

          Yes you are right. That is one thing I am working on.

          But still even if I make them of same size (a smaller size) I would like to center align them. And if I get to center align them above post text, then may be I can work with any image size.

          The problem is that Genesis does not add images in a separate DIV. Which makes difficult to manipulate them from CSS.

          I have found a way to add a image and content in a separate DIV now using following Genesis hook, and now able to center align images, apply borders etc. But there is some problem with this code. I am not able to see more than two posts with this hook active. Trying to figure out that.

          <?php
          /** Change the featured image */
          remove_action( ‘genesis_post_content’, ‘genesis_do_post_image’ );
          add_action(‘genesis_post_content’,’ibfy_post_image’, 0) ;
          function ibfy_post_image() {
          if (  ! is_singular() ) {
          $img = genesis_get_image( array( ‘format’ => ‘html’, ‘size’ => genesis_get_option( ‘image_size’ ), ‘attr’ => array( ‘class’ => ‘post-image’ ) ) );
          printf( ‘<div class=”featured-image”><a href=”%s” title=”%s”>%s</a></div>’, get_permalink(), the_title_attribute( ‘echo=0’ ), $img );
          echo genesis_do_post_content();
          }
          }
          ?>

          Anyway Thanks for the reply.

          in reply to: Center Align Featured Images #4159
          Dinesh Sharma
          Customer

            Alright that is also a possible solution but I would have loved to center align images. I will see if I can get some support from Genesis guys, so that it is possible to manipulate featured images using CSS.

            If I find a better solution I will post it here.

            Thanks,

            Dinesh Sharma

          Viewing 4 posts - 1 through 4 (of 4 total)