• Resolved alexvaxx

    (@alexvaxx)


    Hey there, I have a question that I hope some of you might be able to help me out with.

    So, I’m doing this WordPress-hosted site for a photographer-friend of mine. He wants to have a Projects-frontpage that shows a bunch of thumbnails in different sizes.
    To make it easier for my friend to handle the uploading himself, I want to add a widget to the “Add new post”-page that lets him pick which one of the predetermined (by me) thumbnail-sizes he wants this particular post’s attached image to appear as.

    To recap: he uploads and attaches an image to the post he’s composing, and from a widget/dropdown menu, he chooses if he wants the thumbnail of this particular attachment to be 100px, 150px, 200px and so on when shown on the Projects-thumbnails-page.

    I already know how to do this with custom fields (eg. a field called ‘thumb’ containing a value of the url to the specific thumbnail-size), so that’s not my question; I simply want to know how to make this widget/menu, or if there’s a plugin that any of you guys know of that can handle this–I have been looking, but without luck.

    Thank you very much to everyone in advance.

    //A.

Viewing 1 replies (of 1 total)
  • Thread Starter alexvaxx

    (@alexvaxx)

    So, I kind of fixed this myself, and for future reference I’ll just walk you guys through what I did.

    I’ve added additional, custom thumbnail sizes with the “Additional Image Sizes”-plugin, and simply named them the numbers from 1 to 6.

    When adding a new post, I attach an image using the “Featured Image”-feature, and then I’ve created a custom field called “thumbsize” where the numbers from 1 to 6 can be put in.

    In my template file I retrieve the featured image using the_post_thumbnail() inputting the value from the thumbsize custom field as the name of the thumbnail I wish to retrieve. Also I make sure that if no input or a number higher than 6 is put in, the image size defaults to size 1.

    It look like this.

    if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
      $thumbsize = get_post_custom_values("thumbsize");
      if ( $thumbsize[0] >= 1 && $thumbsize[0] <= 6 ) {
      the_post_thumbnail( $thumbsize[0], array('class' => 'masonrythumb ') );
      }
      else {
      the_post_thumbnail( '1', array('class' => 'masonrythumb') );
    }
    }

    I hope this can be of help to someone. And if anyone has ideas of a better way to solve this, you’re very welcome to comment.

    Cheers.

Viewing 1 replies (of 1 total)
  • The topic ‘Thumbnail-size-handling widget’ is closed to new replies.