Coder Social home page Coder Social logo

voceconnect / multi-post-thumbnails Goto Github PK

View Code? Open in Web Editor NEW
144.0 27.0 63.0 1.16 MB

Adds multiple post thumbnails to a post type. If you've ever wanted more than one Featured Image on a post, this plugin is for you.

Ruby 2.75% JavaScript 17.78% CSS 0.25% PHP 79.22%

multi-post-thumbnails's People

Contributors

banderon avatar chrisscott avatar codelingobot avatar horttcore avatar mboynes avatar rodrigoprimo avatar victmo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multi-post-thumbnails's Issues

Reading the secondary-image.

Hi,

First of all; thanks for the plugin!

I got everything working with one featured image. Now I added the the plugin for a second one and then the problems start. But I can't seem to figure out how to change my code to look at the secondary-image.

I can't seem to figure out what to change in my code to get this working, and it has been hours. So, thanks in advance for the tips and hopefully a solution.

<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnails' );?><div class="background" style="background-image: url('<?php echo $src['0'];?>')"></div>

Trouble using with image size and attribute with a class in it

I am trying to add a class to the post thumbnails but when I add the class it doesn't display the thumbnail. This also happens with the image size and I'm wondering if I'm doing something wrong. I have 2 post thumbnails ID "banner-image" and ID "right-small-image"

In the function.php file I have:

add_theme_support( 'post-thumbnails'  );
add_image_size('slider-background', '975', '345', true);
add_image_size('right-small', '250', '200');
add_image_size('wide-banner', '600', '200');

if (class_exists('MultiPostThumbnails')) {
    new MultiPostThumbnails(
        array(
            'label' => 'Top Banner Image',
            'id' => 'banner-image',
            'post_type' => 'page'
        )
    );

    new MultiPostThumbnails(
        array(
            'label' => 'Top Right Small Image',
            'id' => 'right-small-image',
            'post_type' => 'page'
        )
    );
}

In the page itself I have the code to display the two post thumbnail types:

    <?php
        // If the page has a banner image display it here
         if (class_exists('MultiPostThumbnails')) :
            $attr = array("class" => "banner-feature-image");
            MultiPostThumbnails::the_post_thumbnail(
                get_post_type(),
                "banner-image",
                "wide-banner",
                $attr
            );
        endif; 
    ?>

    <?php
        // If the page has a small right image on the top, beneath the heading, display it here
         if (class_exists('MultiPostThumbnails')) :
            $attr = array("class" => "right-small-feature-image");
            MultiPostThumbnails::the_post_thumbnail(
                get_post_type(),
                "right-small-image",
                "right-small",
                $attr
            );
        endif; 
    ?>

Is there some sort of issue with my syntax? Or is there some sort of bug?

It works just fine when I exclude the image size and the $attr at the end. When I include either of these the image stops showing up in the page and html output.

Thank you for making this incredibly useful plugin and for your time and consideration.

Set as a background image?

Hi folks,

Is there anyway to set the 2nd featured image as a background image, so I can play with background-attachment, that kind of thing?

This is what I currently have -

thanks

Set up with Wordpress

I just activated the plugin and cannot see the box for secondary featured image when creating a new blog post. I checked on your Quick Start page and it mentions some code to be included in the functions.php. I am not so familiar with programming, so I am wondering if you can tell me where exactly that code needs to be inserted. And do both sections you mention in te Quick Start guide need to be included? It would be great to get the same kind of box you published in your screenshot section.

Pulling featured image id's

Hi,

I'm using a slider which requests image ids to create the slides.

How could I request individually or in an array the ids from registered post thumbnails?

Thanks,

Using Multiple Post Thumbnails image as an imagehover

Hi,

I was wondering if there's a way to use the secondary 'featured' uploaded image (thanks to this plugin) as a hover for the first (and original) featured image.

I did find a way to create and choose a single hover image in the themes layout-objects.php-file but I need a string to be able to 'call' the secondary image. Right now, the only thing I'm able to do is setting up a stock image (with text or color) and use that as a hover-image for each and every first featured image.

I need a page with a couple of black and white faces of people. The images used for these faces are the Featured Images, used in articles (posts). When you move over the images with your mouse, these images has to fade into the colored (secondary Featured) images.

The string to call the first (original) featured image looks like this:

code

Does anyone have an idea?

Thanks!

Using plugin in front-end

Hi, i want to get users in front-end ability to upload multiple thumbnail for guest post. how can i do that?

WordPress 3.5 file_frame Modal Boxes Stacking

Thanks for the awesome plugin! I've gotten a change to test the version 1.5 and 1.6 with the new modal boxes on WordPress 3.5.1. I've noticed a strange bug with modal boxes stacking on top of eachother.

Steps to replicate:

  1. Add two post thumbnails to a post or page.
  2. Add a third post thumbnail, after the first two.
  3. Click "Remove" Link on second post thumbnail.
  4. Click "Add" Link on second post thumbnail.

Expected: The second thumbnail modal box to open.

Result: Third thumbnail modal box opens. When you click the "X", the third thumbnail box closes, and the second appears to have been open, just behind the third modal box.

You can replicate this again by closing out the second modal box and clicking the "Add" link on to try to cue the second thumbnail modal box. The same result happens.

Let me know if you're able to replicate this on your end! Thanks!

Outputting metabox by page slug or ID?

new MultiPostThumbnails(
    array(
        'label' => 'Featured image 2',
        'id' => 'featured-image-2',
        'post_type' => page
    )
);

This metabox now appears on all page admin screens. Is there a way to output the metabox by page slug or by page ID? For example, I'd like the metabox to show up on my 'about-me' admin page but not on my 'contact-me' admin page.

Get thumbnail uri inside function

I'm trying to get the thumbnail inside a function... but it doesn't work

function img_two($post_id, $imgsize) { return MultiPostThumbnails::get_post_thumbnail_url(get_post_type($post_id), 'secondary-image', $post_id, $size = $imgsize); }

calling in theme like;
<?php echo img_two(get_the_ID(), 'square_550'); ?>

Getting image caption

Hi, I love this plugin and use it all the time :)

I do have an issue though, I can't seem to retrieve the image caption - I've found this online but it doesn't seem to work. I'm sure there is a simple solution though. If there is it would be good if you could update your docs with it too :)

$second_thumbnail_id = get_post_meta(get_the_ID(), "page_secondary-   image_thumbnail_id", false);
$second_id = $second_thumbnail_id[0];

// The thumbnail caption:
echo get_post($second_id)->post_excerpt;

Multiple Post Thumbnails

I think this happened once I updated to the most recent version of wordpress, but I have not tried to change my images until now. When I try to set an image the choices show up (galley, upload etc.), but I cannot get a response when I click Set or Upload. Nothing. I had removed the 1st image in one of my portfolios and cannot reset it. So that portfolio does not even show up! I tried to deactivate the plugin and it will not deactivate. Please help me! Thanks!

Image not selected in media lightbox

If I click on a MultiPostThumbnail from inside the post edit page (after having set it and saved the post), wordpress opens a lightbox, but the image is not selected (see the attached screenshot).
schermata 2015-04-22 a 16 31 52

Add attributes to the link

Would it be possible to add an option to the the_post_thumbnail and get_the_post_thumbnail methods to add attributes to the link (in the same way that attributes can be added to the image)?

I've got three featured images per post and using fancyBox to display them when clicked, but I need the rel="group" attribute on the links so that fancyBox groups them to give the prev/next navigation in the lightbox.

At the moment I'm using jQuery to add the attributes which works fine, but it would be nice if this could be done via the methods.

Multiple Post Thumbnails doesn't work with Post Thumbnail Editor

Hello,

I just install your plugin on the blog I'm developping and it works. But (always a but), it is not compatible with my other plugin Post Thumbnail Editor.

Lets me explain.
I installed the Post Thumbnail Editor plugin before because it is the best way for my client to resize the post thumbnail directly in the Worpress admin.

But when I installed your plugin, I realize the Thumbnail editor link doesn't appear under the second post thumbnail.
You can see how it appears on Wordpress :
http://www.slasheuse.com/wordpress-bug.png

Do you know, by any chance, how to make your plugin compatible with the Post Thumbnail Editor ?
I already the author but he told me that he didn't know how to fix it.

You're my last chance :)
Thanks in advance

Why prefix the meta with the type of the post?

I'm curious, why are you prefixing the meta keys with post type names ? [post_type][meta/image_id]
This is complicating things when I want to get the image out.
I can't make a clean general purpose function for getting the images out.
I understand why you need the post type when registering images, but why do you need the post type for getting images out ?
ID should be enough to retrieve the images.

Admin thumbnail display

Hugely shallow thing to request, but could the post thumbnail preview image in the admin be styled so it doesn't overflow beyond the padding of the container if it's too wide? It's kind of a visual eyesore when using the extra thumbnail with landscape-style images.

MPT breaks when trying to edit image

In my office we're running 3.9.2. We're able to create a new thumbnail with MPT, but when we select an image and hit the "Edit Image" button on the side bar, instead of opening up in the main media frame like it does for the standardfeatured image, instead it opens up in a new window, making for a poor interaction.

We're hoping you might have some thoughts to this, or any fixes.

Not outputting image correctly for 'Blog' page?

Hey, great work, but having an issue with trying to show an image when a Blog page is set.
It does not pull the featured image that has been set for the blog page, but more the image from the first post??

The code I have currently is -

And then in header.php I have done (as I have slightly differing text) -

if is_page (works great)

else is_singular (works great)

else is_home (this is where the issue arises)

Any pointers dude?

Many thanks

Multipost return values

Hi,
thanks for great plugin!

I have one question, since I'm using multipost plugin to display images in slider (3 slides, 1 image for each). Slider is coded into single.php template file, and I call multipost thumbnail image in each slide, example :

So, I would like to check if multipost item "project-image3" exists, and if it does, I'd like to show slide. If it doesn't exist, slide shouldn't be visible.

Thanks in advance!
Ante.

Post ID not sent to media window

Hi,

In your enqueue_admin_scripts()method you use wp_enqueue_media() but you omit to specify the post ID. It's a problem if a script or a plugin needs that ID in the media window.
Solution:

public function enqueue_admin_scripts( $hook ) {
    global $wp_version, $post_ID;

    // ...
    } else { // 3.5+ media modal
        wp_enqueue_media( array( 'post' => ($post_ID ? $post_ID : null) ) );
        // ...
}

Thanks.
Greg

MultiPostThumbnails::has_post_thumbnail() references $this

It's a static function, so it fatal errors when $this is referenced. I was initially just going to change all the references of $this->meta_key to self::$meta_key and add that static property, but seeing it's a dynamic meta_key value, it's likely not the right solution.

Edit:
Running WP 3.5 and latest master branch of this plugin.

Any way to output placeholder image if not set?

Hi,

Have this currently -

<?php
                    // If the current page is a static page, post or CPT
                    if ( is_page() || is_single() || is_singular( 'portfolio' ) ) {
                        if (class_exists( 'MultiPostThumbnails' )) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'header-image', NULL, 'header-image-full', array('class' => "custom-header-image") ); endif;
                    // If the current page is your posts page
                    } else if ( is_home() ) {
                        if (class_exists( 'MultiPostThumbnails' )) : MultiPostThumbnails::the_post_thumbnail( 'page', 'header-image', get_option('page_for_posts'), 'header-image-full', array('class' => "custom-header-image") ); endif;
                    }
                    ?>

And was wondering if there was an option to show a placeholder image if the thumbnail had not been set?

I can achieve this via the usual route of - if ( has_post_thumbnail($post->ID) ){ .... else ......placeholder.img etc...

But cannot see how I could hook this into your code?

many thanks

Not returning post thumbnail with custom size

Hi Voce Team!
Thanks for your work on this plugin. I'm having an issue where it won'te display the post thumbnail with a custom image size that I've set with add_image_size('slide', 755, 300, array( 'center', 'top' )); in my functions.php.

The code i'm calling in my template is..

if (class_exists('MultiPostThumbnails')) :
MultiPostThumbnails::the_post_thumbnail('post' , 'secondary-image', 'slide');
endif; ?>

Any idea's why this isn't outputting anything at all? If I remove 'slide' from the end, I get the image output, but without my sizing and crop which is specified in add_image_size.

Wordpress Thumbnail

Good day

How can I display the normal thumbnail of WordPress, if no second thumnail was set? So, it isnt working... And if none at all is determined by both, a default image should be displayed
bildschirmfoto 2014-07-20 um 20 36 23

Returning the image URL without the tag

Im trying to return in my template the secondary image URL to inject it with inline CSS as a background.

Is there any way to do so ? So far i've tried this, but it doesnt work :

<div class="article-img" style=" background-image: url(
    <?php if (class_exists('MultiPostThumbnails')) :
        $custom = MultiPostThumbnails::get_post_thumbnail_id(‘post’,   ‘secondary-image’, $post->ID); 
        $custom=wp_get_attachment_image_src($custom,’post-secondary-image-thumbnail’); echo $custom[0];
    endif; ?>); background-size:cover;">
</div>

thank you :)

Swap two feature images randomly on page load.

Not an issue but just some code to alternate two feature images at random on page load.

Use this within the loop:

<?php
// Get a random number
$min = 1;
$max = 10;
$num = rand($min,$max);

// If it is an odd number and we have a feature image

if ( $num & 1 && has_post_thumbnail() ) { 

  the_post_thumbnail(); 

   } elseif ( $num % 2 == 0 && MultiPostThumbnails::has_post_thumbnail( get_post_type(), 'secondary-image', NULL) ) { 

    // If it is an even number and we have a secondary image 

MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image', NULL, ''); // add your thumbnail size as the last argument

  } else { // It's even and we don't have a second feature image so get the default feature image

  if ( has_post_thumbnail() ) { 

 the_post_thumbnail();

  } 

}
?>

Image size

Hi,

How do I display different image sizes of the multiple images with MultiPostThumbnails::the_post_thumbnail.

I tried the following but it doesn't work.

<?php if (class_exists('MultiPostThumbnails')) :
    MultiPostThumbnails::the_post_thumbnail(
        get_post_type(),
        'image2',
        $size='medium'
    );
endif; ?>

I just need the right syntax I think or does size only work with get_the_post_thumbnail()?, because when I use that it returns nothing.

Thanks for your time

Support for Jetpack's Photon and WP 3.5 new Media tools

Great plugin! It helped me a lot developing a rollover effect for Jigoshop's catalog.

Jetpack's Photon feature is fantastic, but apparently this plugin is not rewriting images URLs, even in loop.

Also, maybe it's too early (3.5 was just released yesterday) but I noticed that this plugin is still using the old media handler.

I don't know how to use it with WPML

I use in a web page with WPML for different languages, but it does not show the thumbnail.

How can I make the query to show the mutilple thumbnail?

Regards.

Using plug-in in conjunction with ThreeWP Broadcast plug-in

Hello,

I've got a multi-site set-up that uses this plug-in https://wordpress.org/plugins/threewp-broadcast/ to push the content from the main site to the sub sites. Your plug-in is working great on the main site, but when I save and broadcast to the sub-site the "Secondary Image" field has no image associated with it.

If it helps in trouble shooting, things are working as I hoped using the native "featured image" wordpress comes with. Thanks for any thoughts you may have.

mark

Incompatibility with AWS plugin?

Hi, I am using this plugin for getting two images per post. I am also using the amazon web services plugin because I need my images on an S3 bucket. but when I am getting back the 'second featured image' the url points to the 'domain' url, it is not updated properly as it is the main featured image.
This is what I am using to pull the image url:
$secondary_thumb_id = MultiPostThumbnails::get_post_thumbnail_id('post', 'secondary-image' , $value->ID);
Any way to change it?

Exporting thumbnail images with custom post types

Thanks for the great work on this plugin. I have an issue/feature request. I need to export several custom post types which use this plugin. The problem I run into is that the images do not export with the post types. The custom metadata exports fine, but the images do not. I realize this is technically due to the way the native wordpress exporter works, but I believe the problem actually boils down to the manner in which the plugin associates images with post types. I can think of two possible solutions off the top of my head.

  1. Provide a custom exporter plugin to work around this situation when users export partial content from their blogs.
  2. Force an association between every thumbnail with its parent post type. In situations where the image is already associated with a post type, duplicate it and associate the copy with the post type.

I've prototyped them both, and they work, but neither feels like a good general solution. I'd like to hear your thoughts.

Translations

There seems to be some issues with the .pot-file. I can't get it to find the "Remove"-translation. Any ideas why?

MultiPostThumbnail only in custom template page (metabox)

I have several pages: About-us, Home, Proyects, etc.
When I use the function

if (class_exists('MultiPostThumbnails')) {
    new MultiPostThumbnails(array('label' => 'conocenos','id' => 'imagen-conocenos','post_type' => 'page'));
    new MultiPostThumbnails(array('label' => 'Imagen 2','id' => 'imagen-2','post_type' => 'post'));
    new MultiPostThumbnails(array('label' => 'Imagen 3','id' => 'imagen-3','post_type' => 'post'));
    new MultiPostThumbnails(array('label' => 'Imagen 4','id' => 'imagen-4','post_type' => 'post'));
    new MultiPostThumbnails(array('label' => 'Imagen 5','id' => 'imagen-5','post_type' => 'post'));
}

the first one post_type=>'page' is showing in every page.
How can I enable it in Home but disable it in About-us, Proyects, etc?

Thanks in advance!

JS error when clicking "Choose ..." button in side meta box

I'm running WP 3.5, and latest master of the plugin. When clicking the side meta box's button for choosing the secondary featured image, I'm getting a JavaScript error as follows:

Object [object Object] has no method 'on' 

frame.toolbar.on( 'activate:select', function() {

I've not dug into the new media management UI to be able to submit a patch yet, but wanted to at least put this out there.

Could not set that as the thumbnail image message

running the plugin inside of CherryFramework. Added this code to the post-type init
new MultiPostThumbnails(
array(
'label' => 'Formal (Interior) Image',
'id' => 'team-secondary-image',
'post_type' => 'ourteamfolio'
)
);

Can see the meta-box like I am expecting.
image

When I try to set the image, for all images in our site - I keep getting a javascript pop-up which says "Could not set that as the thumbnail image, try another image" message box.

image

Any thoughts?

compatibility with 4.2.2

Hi,
I am using Wp 4.2.2, installed the latest available version of Multi Post Thumbnail its installed without any problem, activated the plugin but still cannot see any extra Featured image options while trying to add a new post or edit an existing one, tried by deactivating and re-activating the plugin but still no Luck, also tried with WP 4.1.x but same problem.

help please

Using as background image on a page

Hello,
I would like to use this to display a background image on a page, not a post.

Heres the code i am using:
style="background: url(<?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::get_post_thumbnail_id('page', 'background-image'); endif;
My function:
if (class_exists('MultiPostThumbnails')) { new MultiPostThumbnails(array( 'label' => 'Background Image', 'id' => 'background-image', 'post_type' => 'page' ) ); }

However it does not display. When I use the regular "the_post_thumbnail" in the theme code, it will work correctly, but thats to generate the full image tag. Please let me know how to accomplish this on a page. Thanks.

Adding images to multi-post-thumbnails fields using XML-RPC

I just learned that I need to migrate data from an old sql database to a WP publication. The publication uses multi-post-thumbnails, and I need to direct the image data to the corresponding fields in the posts.

Adding an ordinary thumbnail using post_thumbnail in wp.newPost is easy, but how do I add a multi-post-thumbnail?

I tried 'post_custom_fields' => array( 'post_[field-name]_thumbnail' => $imageid ) but that was obviously wrong.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.