Pregunta

¿Hay una manera de dejar que mis usuarios definen el área de cultivo de un puesto miniatura? Las miniaturas son siempre los archivos adjuntos de correos existente, preferiría no crear un archivo adjunto extra por miniatura.

Las miniaturas de correos debe ser de 200x100 píxeles, y provienen de una de las imágenes utilizadas en el puesto. Así que en mi mundo ideal, al hacer clic en el enlace "conjunto de imágenes destacadas", se obtiene una visión general de las imágenes ya incluidos, y al hacer clic en uno de estos, se puede definir el área de recorte a sí mismo (en movimiento o cambiar su tamaño, pero manteniendo la relación de aspecto 2x1). Al hacer clic en "Aceptar", el nuevo puesto miniatura se guarda con el archivo adjunto original (en el campo de metadatos _wp_attachment_metadata['sizes']['post-thumbnail'] por ejemplo), no como un nuevo archivo adjunto. El uso de una imagen que ya se utiliza como un puesto de miniatura para otro post no debe permitirse, o al menos dar una advertencia.

Creo que el editor de imágenes incluido no se adapte a mis necesidades, ya que se puede optar por editar todas las versiones de la imagen, o la miniatura regular, pero no sólo el puesto en miniatura. También creo que es un poco confuso saber qué versiones estoy editando, así que creo que mis usuarios tendrán aún más problemas con él.

¿Hay un plugin que hace lo que yo quiero, o que pueda extenderse fácilmente a mis necesidades?

Actualización: Ejemplo UI

A mi me gusta la interfaz X de la libreta de direcciones de Mac OS selector de imagen: permite seleccionar una imagen, y redimensionar una relación fija miniatura cosechador a través de un control deslizante. También puede arrastrar el alrededor de la imagen de base. Puede ampliar esta idea para múltiples tamaños de imagen (Tengo un post-thumbnail y post-thumbnail-1/2 que es la mitad de ese tamaño, por ejemplo). Permitir al usuario seleccionar los tamaños (s) que se está editando ahora con casillas de verificación, y dibujar los rectángulos de cultivos apropiados en la pantalla.

La libreta de direcciones imagen cosechador en acción

¿Fue útil?

Solución

The code is still a mess, but it seems to work, even on IE 8. I plan to release it in the repository, but in the meantime you can play with my current version. To access it you click the "Edit Image" when adding or editing an image, it replaces the usual image editor (they are very hard to combine). Since most of the admin area uses the regular thumbnail and my current version edits the post thumbnail, it might seem the code has no effect, but try it by showing a post thumbnail and you should see it change.

This plugin requires my On-Demand Image Resizer, which is also still a mess, to do the actual resizing.

Example image in the cropper

Otros consejos

Your best bet is to use a javascript based image crop and then php combined with ImageMagick or Image GD.

It would have to be written into your functions or as a plug-in as I don't know off hand of any off the shelf wordpress plug-ins, which is surprising.

There is a YUI image crop with php based save option http://developer.yahoo.com/yui/examples/imagecropper/conn_crop.html

Here is a different tutorial on how to use a jquery cropper with php
http://www.webmotionuk.co.uk/php-jquery-image-upload-and-crop/

A third option very similar to the above link using the same jquery cropper but different code. http://www.leonkessler.com/blog/?p=132

Here is another using jquery's jcrop instead, http://www.talkincode.com/jcrop-extension-implementation-in-php-932.html

Who is up for a new plug-in, this would surely be popular:)

Assuming you already have added support for post-thumbnails, as you're talking about the "Featured Image" option.

If so, one option you have it to add a new image size to the upload array. So by default, you have thumbnail, medium, large. In the following bit of code, this adds a 4th image to that assortment, based on whatever size you desire. This bit of code would be added to your functions.php file.

add_image_size( 'new_thumb', 200, 100, true );

"new-thumb" = the name of the new custom image
"200" = width
"100" = height
"true" = hard crop option. This will force an image to be cropped to the defined width/height. Without, it just scales to proportion.

Now, to display the new thumbnail on a page or post array, you would insert the following into your HTML

<?php the_post_thumbnail('new_thumb'); ?>

You might want to use CSS in order to have big flexibility, fix thumbnailing in your theme (if wanted) and avoid file clutter:

http://www.seifi.org/css/creating-thumbnails-using-the-css-clip-property.html

Remember that the whole image will be loaded, so do not use your 3MB originals for this.

Update as per request of Jan: If you do want dynamic clipping, consider:

  • For user=administrator, create CSS via PHP; you can just link to the php that reads the appropriate settings and adjust clipping parameters accordingly.
  • For user=visitor, use JavaScript to change clipping parameters in the image's style attribute.
  • As a less invasive solution, consider creating a shortcode (via the great plugin Shortcode Exec PHP) like [thumb w=?? h=??]url[/thumb] that you can translate to the appropriate HTML tag with inline CSS.

There's an older plugin called WP Post Thumbnail that we sometimes use. It's not perfect, and there are some minor bugs with the latest version fo WP (it hasn't been updated since 2008 so it's not necessarily reliable). http://wordpress.org/extend/plugins/wp-post-thumbnail/

I believe you are looking for this: http://wordpress.org/support/topic/scissors-for-wordpress-29-also-works-on-30-hurray

I haven't tried this out, but it should offer you the functionality you are looking for.

The original plugin page here. http://wordpress.org/extend/plugins/scissors/

I'm needing this for a project I'm working on, too.

I think the ultimate solution to this problem would be to modify the plugin from http://www.seoadsensethemes.com/wordpress-wp-post-thumbnail-plugin/

and customize it so that any custom image sizes defined within your functions.php file (using add_image_size( 'new_thumb', 200, 100, true ); ) automatically get used and then get the code to replace (or extend) the "edit" link when you want to modify an image.

Utilizing this approach wordpress can continue to create its applicable image sizes as it normally does but if you want to specifically modify the cropped area of any specific image you have the ability of doing so which in turn would replace the automatically generated image for that size. Hmmm... although that sounds confusing reading over it again its exactly what I feel is missing.

Currently I believe the plugin saves these custom image sizes to a custom field within a post instead of a the post for an applicable image.

I've decided to crop thumbnails using the native "wp_get_attachment_image"... here goes an example of a image gallery, with cropped thumbnails

http://wpworks.wordpress.com/2010/12/27/image-gallery-with-image-crop/

Best Regards

Licenciado bajo: CC-BY-SA con atribución
scroll top