• Thanks for a very useful plugin – working as a charm in all kind of installs, by many clients. However, we been missing some filters for a while and would like to request following.

    The pinterest output is hard to control. We manage to walk around the lack of description filter, by filter the post meta to belive there is a populated meta for the post. But still, the size of the image cant be filtered, and replacing the url is messy as the attachement_id is commonly delivered by those statements:

    $pinterest_img = $this->pinterest_image() ? $this->pinterest_image() : $this->attributes['image'];

    Where-ever the attributes[‘image’] or pinterest_image() are populated, we would like a filter.

    This filter is found:

    return apply_filters( 'scriptlesssocialsharing_image_url', isset( $source[0] ) ? $source[0] : '' );

    Not so useful. We need a filter for the image size before there. And as $id not provided, we must track the image all over again to change the url (if has thumbnail…get_the_ID…attachment_id…get..)

    Same for the pinterest own description, a final filter (with all args provided) would be nice:

           /**
    	 * Get the description for Pinterest.
    	 *
    	 * @since 2.2.0
    	 *
    	 * @return string
    	 */
    	protected function get_pinterest_description() {
    		$pinterest_alt = get_post_meta( get_the_ID(), '_scriptlesssocialsharing_description', true );
    		if ( $pinterest_alt ) {
    			return $pinterest_alt;
    		}
    		$pinterest_img = $this->pinterest_image() ? $this->pinterest_image() : $this->attributes['image'];
    		$pinterest_alt = get_post_meta( $pinterest_img, '_wp_attachment_image_alt', true );
    
    		return $pinterest_alt ? $pinterest_alt : $this->attributes['title'];
    	}
    

    In this case we would prefer:

    $description = $pinterest_alt ? $pinterest_alt : $this->attributes['title'];
    $attachment_id = $this->pinterest_image() ? $this->pinterest_image() : $this->attributes['image'];
    
    return apply_filters('scriptlesssocialsharing_pinterest_description', $description, $attachment_id, $pinterest_alt, $this->attributes['title']);

    Thanks – and cheers for all good work!

    • This topic was modified 4 years, 6 months ago by Jonas Lundman.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Robin Cornett

    (@littlerchicken)

    Hi Jonas!

    There is an earlier filter to change the Pinterest image size which may be what you want:

    
    apply_filters( 'scriptlesssocialsharing_pinterest_image_size', 'large' )
    

    You can update that to use any registered image size name. I’ll look into adding parameters to the image URL filter–you are right, that would be a lot more helpful!

    If you want to modify the Pinterest description in the final button output, you can use the existing scriptlesssocialsharing_pinterest_query_args filter and modify the description in the array, but I agree, having a filter in that method would be helpful–I’ll look into adding that as well.

    Thread Starter Jonas Lundman

    (@jonas-lundman)

    Hi and thanks for the answer.

    That filter seems only to affect the “hidden” pinterest at the end of the content of using manual inserted in edit post box.

    We need to filter the button url.

    Thanks

    Plugin Author Robin Cornett

    (@littlerchicken)

    Ah, I see. I think it would be reasonable to apply the same image filter there, so I can make that change.

    Thread Starter Jonas Lundman

    (@jonas-lundman)

    Hi and thanks again for your time. The filter would be great, also consider to pass the calculated id as argument in the mentioned filter, so we know the image we are dealing with, “unique” for that post (saved in post edit meta box) or the featured image found and propably in the $this->attributes['image']

    Cheers!

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

The topic ‘Missing filters’ is closed to new replies.