Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter robsf

    (@robsf)

    Edit

    Thread Starter robsf

    (@robsf)

    Ok, installed Featured Image 2, enabled it on the Portfolio post type, used the code from the link above and the code to define the thumbnail size and it’s giving me a great result.

    Resolved!

    Code for anyone interested in future

    Set thumbnail size:

    function wp_tiles_custom_image_size( $size ) {
        return 'large';
    }
    add_filter( 'wp-tiles-image-size', 'wp_tiles_custom_image_size' );

    Return Featured Image 2 (whilst retaining other image types) into wp-tiles

    add_filter( 'pre_wp_tiles_image', 'homepage_tiles_porto', 10, 2 );
    function homepage_tiles_porto( $src, $post ) {
        $tile_image_size = apply_filters( 'wp-tiles-image-size', 'post-thumbnail', $post );
    
        $images = get_children( array(
            'post_parent'    => $post->ID,
            'numberposts'    => 1,
            'post_mime_type' =>'image'
        ) );
    
    	if( ! empty ( $images ) ) {
                    $images = current ( $images );
                    $src = wp_get_attachment_image_src ( $images->ID, $size = $tile_image_size );
                    return $src[0];
                }
    
        if( !empty( $images ) ) {
            $images = current( $images );
            $src = jeg_get_image( $images->ID, $size = $tile_image_size );
            return $src[0];
        }
    
    	if ( $post_thumbnail_id = get_post_thumbnail_id( $post->ID ) ) {
                    $image = wp_get_attachment_image_src( $post_thumbnail_id, $tile_image_size, false );
                    return $image[0];
                }
    
    			    if( !empty( $images ) ) {
            $images = current( $images );
            $src = kd_mfi_get_featured_image_url( $images->ID, $size = $tile_image_size );
            return $src[0];
    				}
    
        return '';
    }

    I’m sure it aint pretty, but it works.

    Thanks for all your help Mike, so relieved.

    Rob

    Thread Starter robsf

    (@robsf)

    Theme developer has confirmed it’s porto_gallery_cover so I guess I have the code to implement it wrong. Either that or it’s not working for any infinite amount of other reasons :/

    Thread Starter robsf

    (@robsf)

    I’m confident I’ve got your code right, I can edit the code and make the already working Blog images not show up from the stuff I’ve pasted into functions.

    I’ve been through all the files and picked out anything I could see with underscores in it that related to portfolio images and substituted them all in the code with no joy. I’ve now resorted to emailing the theme creator to see if he can give me a definitive answer on exactly which field holds the image – as far as I can tell none of them work. Frustrating stuff.

    Cheers

    Thread Starter robsf

    (@robsf)

    I’m in a hopeless situation here I think, I’ve found what I believe defines the gallery image location on the Portfolio-item template, pasted that into some code from the link you gave, added that to functions.php and it’s not having any of it.

    What I believe to be the relevant items from portfolio-item.php:

    $mediatype = j_get_meta('portfolio_media');
    	$icontype = "" ; $covername = "" ; $imageCover = "";
    
    	switch($mediatype) {
    		case 'gallery'	:
    			$covername = "porto_gallery_cover";
    			$imageCover = JEG_CSS_URL . 'img/cover/gallery.jpg';
    			$icontype = " icon-picture ";
    			break;

    and

    <img src="<?php echo jeg_get_image($imageCover, '', $jdata->portoItemWidth, $jdata->portoItemHeight)?>"/>

    My code butchered from the page above (I didn’t want it to ONLY show those type of image – wanted to make it show those when it couldn’t find a featured image – the bit with my code in it is in the middle):

    add_filter( 'pre_wp_tiles_image', 'portfolio_gal_cover_tiles', 10, 2 );
    function portfolio_gal_cover_tiles( $src, $post ) {
        $tile_image_size = apply_filters( 'wp-tiles-image-size', 'post-thumbnail', $post );
    
        $images = get_children( array(
            'post_parent'    => $post->ID,
            'numberposts'    => 1,
            'post_mime_type' =>'image'
        ) );
                if ( $post_thumbnail_id = get_post_thumbnail_id( $post->ID ) ) {
                    $image = wp_get_attachment_image_src( $post_thumbnail_id, $tile_image_size, false );
                    return $image[0];
                }
    
    			    if( !empty( $images ) ) {
            $images = current( $images );
            $src = porto_gallery_cover( $images->ID, $size = $tile_image_size );
            return $src[0];
        }
    
                if( ! empty ( $images ) ) {
                    $images = current ( $images );
                    $src = wp_get_attachment_image_src ( $images->ID, $size = $tile_image_size );
                    return $src[0];
                }
    
        return '';
    }

    At the end of the day, it has to be pulling the image from somewhere, I think I know where that is from the code from portfolio-item.php but I’m lacking in the ability to correctly implement it and lacking in understanding about how these various functions of WordPress link together.

    If you could help at this point, it would be much appreciated. I can arrange to recompense you for your work with little issue, this is a company website afterall.

    Many thanks,

    Rob.

    Thread Starter robsf

    (@robsf)

    And with one click, the problem was solved.

    Setting in the back end called Curtain Mode, didn’t mention AJAX but it was the only one that related to how a page loads, turned it off and it’s working fine now!

    Thanks again!

    Thread Starter robsf

    (@robsf)

    Ah. Good stuff!

    I’ll have a look into it then, at least I know what the problem is now.

    Thanks so much for your advice.

    Kind regards,

    Rob.

Viewing 7 replies - 1 through 7 (of 7 total)