The first image in the thumbnail is the wordpress plugin. Connecting wordpress thumbnails, tweaking that victoria. #4 We accept only URL miniatures

Golovna / Optimization of work

Today, in a short glance, we will look at one way to install miniatures, and not in manual mode, but on automatic. It’s even more convenient, especially if the material is rich and you don’t have to manage to create a preview of the image for the skin recording. Otherwise, if there are articles, they have been published for a long time, and at that time they did not transfer to the same miniatures. But from that hour it could change, including the need to show miniatures. I want to save the old look and vanish routine work, speeding up with one trick, which will set the miniatures in automatic mode.

Open the functions.php file, it should be in the middle of your theme. In the beginning, before the sign?>, we add an offensive code:

// Autom. thumbnail if (function_exists("add_theme_support")) add_theme_support("post-thumbnails"); function catch_first_image() (global $post, $posts;$first_img = ""; ob_start(); ob_end_clean(); $output = preg_match_all("/ /i", $post->post_content, $matches); $first_img = $matches ; if(empty($first_img))( $first_img = bloginfo("template_url"). "/images/default.jpg"; ) return $first_img;

How to practice: If the entry does not match the thumbnail, then for the help of the function preg_match_all there will be a search for the presence of the picture in the article. After what is known before, the image is presented as a miniature of the post. In addition, even though the article does not show a proper image, it also contains a stub, which is located behind the address "/images/default.jpg" .

Now it is no longer enough to add visnovkas more than the assigned function for the singing area. Showing a file, for example, index.php and others, which can prevent the display of thumbnails (search.php, categories.php, archive.php, etc.). We insert one row of code:

"alt="(!LANG:(!LANG:!}!}"/>

Where should I insert the next? for the standard function of displaying thumbnails.

"> "alt="(!LANG:(!LANG:!}!}"/>

Vipadkov's miniature

If (function_exists("add_theme_support")) add_theme_support("post-thumbnails"); function catch_first_image() (global $post, $posts;$first_img = ""; ob_start(); ob_end_clean(); $output = preg_match_all("/ /i", $post->post_content, $matches); $first_img = $matches; if(empty($first_img))( $random = mt_rand(1, 10); //number of random images from 1 to 10 (" stylesheet_directory"); echo "/images/random/".$random.".jpg"; ) return $first_img;

This variant is similar to the first one, krim, vipadkovy miniature. To replace one picture, as it appears as a stub, it is generated in the specific order of the image from the assigned folder. Just create a folder under the name " random» images". Let's try to take some pictures in jpg format, give the names in numbers (for clarity) and make sure to create a "random" folder earlier.

I live! Today I will tell you about super plugins for displaying WordPress posts. These plug-ins will help you to enter either a side or a post on your site – Stylish Post Announcements. In the announcement, you can show the image of the post, the title, the lyrics, the author, the date, the category. You can watch announcements not only from records, but from sides.

Viewer plugin for displaying post announcements on that side. Visnovok for categories and tags. 4 styles to choose from. Possibility of mood zvnіshnіy look. You can enter the name of the category on the side of the announcements, so that when you press on the category, only the entries from the third category appear. How to configure the plugin -

Super widget for viewing post announcements. Visnovok for categories, labels, authors. Improving the splendid look, expanding the image. You can add the date, author, category. Wide and fluffy lashings. The best widget for viewing records! How to configure the plugin -

Stylish new entries in looking tiles. View entries by category. You can choose the color of the tiles. You can enter on the side a list of the current categories for the site, so that when you click on the name of the category, records from the category of the category appear, in Ajax mode. How to configure the plugin -

5. Post Grid

Super stylish, adaptive, recording system! Choose the effect of the hovering hour, choose the color of the background of the recordings. Visnovok for categories is too thin. How to configure the plugin -

Thumbnails to articles on wordpress blozі - it's also a simple and handy function that allows you to post explaining images in a matter of seconds. Ale, vrakhovuyuchi scho pіdtrimka miniatures at the wordpress platform recently filed, a lot of templates in yoga just don’t support and explain the pictures in the old templates to stand right in the text.

І, when trying to twist the function of miniatures in the template, duplication of pictures is added - the old picture is overwritten and the miniature appears. Good, how is the blog kept for a few months, and how is it for a few years (do not bother with pictures for a whole day)? But you can also check out the help of the wonderful plugin Auto Post Thumbnail.

Plugin Auto Post Thumbnail allows thumbnails of the image from the first image in the post. If the miniature is already installed, then nothing is shown. The plugin is easy to use, but the smut is effective.

Installing this plugin is extremely simple, just grab it from the official site of the retailer and install it by tying it into the folder with plugins for additional FTP support, or for the big gain for the blog admin.

After you have installed the plugin, a new item will appear in your blog menu with the name of the plugin - Auto Post Thumbnail, in which case there is only one Generate Thumbnails button, clicking on it will generate thumbnails to all the main posts in your blog.

After the completion of the robotic plugin, I recommend that you go through the blog, in order to review the posts correctly. If dubbing is required - two pictures are like a miniature, then your template should have a thumbnail earlier, in order to correct the pardon, it is necessary to make some changes in the code of the template. And you can edit the the_content function yourself, replacing php_the_content with

all files have themes in home.php, archive.php, index.php and others, skrіz, de won є.

For this reason, miniatures are shown in short notes, and miniatures are shown in the latter, as you ask before posting. And again, I’ll say it again, it’s easier to create modern templates that support all the necessary functions, the same templatemonster will propagate similar wordpress templates for you. moreover, there are paid, and no-cost options. Ale. if you don't want to be separated from some kind of likeable template, then this way is for you.

Danish plugin will help you to an old, but dear to you project, get a modern look.

About plugin for creating thumbnails for WordPress

After activation, the plugin does not do anything, after starting the process, it will be necessary to edit the template (click on the function in that area, de-needed miniatures of the image). If you just install and activate the plugin, you won't do anything!

In general, the script is similar to timthumb.php, however, it looks a little better:

    It is not necessary to manually create more of the field to send to the picture. The field is created automatically.

    Pratsiuє trohi shvidshe timthumb.php - I zrobiv everything, schob script pratsyuvav maximally fast, daily conversions without gostroy nebhіdnostі, at vsom tsyom help cache;

    The cache is cleared manually. In timthumb.php, the cache is constantly updated, old files are deleted. Resources are going to be re-verified (dribnitsya, but all the same). On tsioma you can zaoschadzhuvati;

    Resizing can be featured right next to the post by specifying class mini pictures and resizing required;

    It's more convenient to tag when integrating into a WordPress theme: you don't need to take the value of a specific field, change the original field to enter a placeholder image. Everything is set up automatically.

  1. There are a lot of hacker attacks on timthumb.php.

The principle of robotic Kama Thumbnail

I create a cache folder: wp-content/cache/thumb. They will create all miniatures.

Miniatures are created skin once, if one of the plug-in functions for creating miniatures is called - more than 3: kama_thumb_src(), kama_thumb_img(), kama_thumb_a_img(). You can pass to the function the expanded thumbnail and the URL of the image, for which you need to generate the thumbnail. The URL of the image can not be passed, but the function is to shukatime the image for streaming recording.

How is the plug-in looking for an image for streaming recording? When publishing or updating a post, the plug-in sends a message to the original image and writes it in the correct field of the post, then a miniature is created for those who posted it. The force is assigned in the following order:

    If you post a WordPress thumbnail, it will be accepted;

    If the post does not have WP thumbnails or pictures in the text, then the plugin can't interpret any post that has been captured by this picture (insert). If the deposit is є, then the message will be taken there;

  1. If nothing is found, then the next field will be filled with a stub record: "no_photo". It’s necessary, so that you don’t have to work for the sake of the operation for asking for help.

When you open the plugin, you see everything: additional fields, options for the data base, image cache, cache folder.

Whiskerstand (parameters)

After installing the plugin in the template, you can tweak the functions:

// Turn the URL of the created thumbnail echo kama_thumb_src($args, $src); // turn image ready (img tag) echo kama_thumb_img($args, $src); // Rotate the posted image. Posilannya lead to the original picture. echo kama_thumb_a_img($args, $src); // Subtract the width or height of the image. But be it the power of a copy of the class, // whoever creates the picture. Sound there you may need only the width and height... // the function is needed if a miniature is created without a front view of the width and height... echo kama_thumb($optname); // Stock: echo " // in this case, it's better to vikoristove and ready kama_thumb_img() won't hurt you... $args (row/array)

Arguments for creating a miniature. All possible parameters:

$src (Row)

For this type of plug-in, it is not possible to remove the message from the post, but rather I will show the picture here.

You can enter a number, then the plugin will enter the input ID of the WordPress media file and automatically take the URL of that media file and process it...

For the lock: ""

Although the parameter is passed as an array, the other $src argument can be passed to any array, with the key: src , url , link or img:

echo kama_thumb_img(array("src" => "http://yousite.com/IMAGE_URL.jpg", "w" => 150, "h" => 100,));

notes

Parameters can be specified in a row or array
// in a row kama_thumb_img("w=200 &h=100 &alt=image name &class=aligncenter", "posted on a certain image"); // "Sending to a certain picture" is to be declared as another argument of the function. To that, you can ask for your own parameters, so that you don’t hesitate with the appointments. // or array (recommended) kama_thumb_img(["width" => 200, "height" => 150, "class" => "alignleft", "src" => "", ]);
You can specify more width or height

The same lengthwise bik (height or width) will be selected in proportion to the copy;

src parameter

It is necessary for vipadkіv, if it is necessary to create a miniature to be a picture.

If the parameters are passed in a row, src must be specified in another argument to the function.

Cache cleaning

Plugin customizations have two cache clearing buttons: "all cache" and "stub cache". Useful for plugins, if for some reason the plugin could not create a thumbnail on the URL. In this way, a stub is created for the picture, so that you don’t have to create a picture for the next hour. When the cache of stubs is cleared, only stubs are visible and for all stubs, the plugin is prompted to create thumbnails again.

To the fact that you were rapted, that the plugin did not create thumbnails for some pictures, then try clearing the cache of the stubs.

Images from other domains

For promotions, you can create images from either the streaming domain or subdomains.

To create an image from external domains, specify the names of allowed domains in plugin settings: Customization - Media files or in the parameter allow pid hour of the weekly function.

If you want to name the domain(s), please specify any , you will be allowed to create images from any domain(s).

Thumbnail of the text of the article (shortcode)

If the article needs to change the picture and send it to the original, then indicate the picture class mini and set the size requirements (width or height).

For example, we inserted a picture before the article:

Ale is not so great, but the need to change is not visual, but real. For whom we can add the mini class to it, it is necessary to expand it (width="300"):

Height, yak we saw, will be picked up automatically, proportionally.

Such a pidhid - don’t hack the shortcode, I’m better off: we can create thumbnails to pictures and when you do it, the picture looks like when you edit a post, also when you can see a plugin, pictures in posts, like before, will be displayed (do not lose your mind) .

To create a thumbnail image, this option must be enabled in the Kama Thumbnail settings: Settings > Media files.

Rechecking the language installation of the plug-in

If you win this plug-in, then, better for everything, the theme will not work without a new one. To do this, it is good to recheck the front of the coristuvacha, as well as to enable the plug-in, that the shoe plug-in and it is necessary to enable it for the correct work with those.

For whom to place such code in the theme functions.php file.

// kama plugin thumbnail if(! is_admin() && ! function_exists("kama_thumb_img"))( wp_die("Enable plugin language kama Thumbnail"); )

Now at the time of deactivating the plugin, at the front end of the koristuvach, a prompt will sound: "Activate the bindings for those Kama Thumbnail plugins".

Swidth of robotic functions

The first processing of the picture is long and fast to lie down in the view of the expansion of the image. Other cuts are already richly swedish, for those who take cash.

The simulations were carried out on paintings with a size of 32KB (650 × 350), for which a miniature with a size of 100 × 100 was created.

  • kama_thumb_src() - 1 time = 0.01403, 50,000 times = 0.54830 sec. (due shvidko)
  • kama_thumb_img() - 1 time = 0.01471, 50,000 times = 1.38748 sec. (shvidko)
  • kama_thumb_a_img() - 1 time = 0.01471, 50,000 times = 1.72967 sec. (shvidko)

When working with cache, but 99% of the robotic plug-in, there is no difference between the picture and the picture...

Notice about the need to install this plugin

It's possible that your theme is either a plugin or a vicorist plugin, and it needs to be installed for the correct work. So, for example, a plugin that does not install a theme may not be practiced, because it has a feature that is simply not available in PHP. Let's see such a moment that we can see the PHP pardon parity NOTICE:

If(! function_exists("kama_thumb_src"))( add_action("admin_notices", function()( echo "

". __("This will require the Kama Thumbnail plugin. Install it please.", "dom") ."

function kama_thumb_src()() function kama_thumb_img()() function kama_thumb_a_img()()

Apply

#1 We accept the miniature

In the middle of the WordPress cycle, you need a thumbnail before the post, with dimensions of 150x100, you can use the following code:

As a result, a ready tag will appear on the place of the code :

#1.2 Changed the picture just behind the indicated side

Sob not framed proportionally change the picture on the designated side: in width or height, you need to specify only the width or height, then the opposite side will be selected proportionally. There will be no kadruvannya with whom.

Kama_thumb_img("w=200");

Now the width will be 200, and the height of the yak will be wide ... With this, the picture will be completely new, without framing.

#2 Placeholder image not displayed

So that the stub image is not displayed, since there are no images recorded, it is necessary to set the no_stub parameter:

#3 Rechecking the visibility of the image for the record

If you need to revise what is in the post picture and if not, then work it out, then twist the following code:

$img = kama_thumb_img("w=150 &h=150 &no_stub"); if(! $img) echo "There are no little ones";

#4 We accept only URL miniatures

It’s not necessary to enter the ready img tag, but it’s necessary to take only a few hints for the thumbnail, so that we can hack it, tag the kama_thumb_src () function:

Rotate the thumbnail URL: /wp-content/cache/thumb/ec799941f_100x80.png . Tsei URL can be vikoristovuvaty, for example, like this:

"alt="" />

#5 We accept a miniature-posted on the original

If you need to create a miniature, like a picture, after squeezing it like a large image, then write the following code:

#6 We accept a miniature for sending a picture

If you need to create a thumbnail for the same picture (not a picture for the text of the article), you can pass another argument to the function, which should be sent to the picture.

$src = "http://domain/image.jpg"; echo kama_thumb_img("w=150 &h=100 &class=alignleft", $src);

#7 post_id parameter

Thumbnails are created behind the caption for a streaming post, like the records of the global changing $post. In some cases, the change was assigned incorrectly and the pictures can be created later, as they are worthy of another post. To accurately designate for which post can a thumbnail be created to designate post_id . If a week click is shown in a WordPress Cycle, then this parameter is not required!

#8 Images from other domains: allow parameter

Also, in the plugin settings, on allowed hosts, the required host is not set and the any row (allow all domains) is not set. Allowed domains can be specified in the allow parameter:

Our domain is site.ru, but we need to create a picture for the site "http://static.othersite.ru/img.jpg".

// you can specify exactly echo kama_thumb_img("w=200&h=150&allow=othersite.ru", "http://static.othersite.ru/img.jpg"); // or you can specify for everyone, so that you can create any site echo kama_thumb_img("w=200&h=150&allow=any", "http://other-site.ru/img.jpg"); // you can definitely specify the number of domains through whom echo kama_thumb_img("w=200 &h=150 &allow=othersite.ru, foo.com", "http://foo.com/img.jpg");

Wiki is not like a plugin (integration with the theme)

As you develop the theme, you will need the functionality of the plugin, but you will not need to install the plugin. This plugin can be selected not as a plugin, but as a part of those or as a mustuse plugin.

To do this, you need to copy the plugin folder (with multiple files) to the themes folder and add the main plugin file kama_thumbnail.php to the functions.php file. Tse everything!

For example, the theme has the includes folder and copied the plugin folder to it, then the head file needs to be added like this:

Require_once "includes/kama-thumbnail/kama_thumbnail.php";

Witness side of options

There is no need for additional options (rob the client's website). That її can be vimknuti. For which it is necessary to specify the required options through the kama_thumb_def_options filter. You can do this in the functions.php file or deinde:

// Revise the parameters of the Kama Thumbnail plugin // Automatically turn on the option side in the admin panel and the option list. add_filter("kama_thumb_def_options", function($opts)( /* output, plugin div code "meta_key" => "photo_URL", // naming the post meta field. "cache_folder" => "", // redirect to the folder ) thumbnails "cache_folder_url" => "", // URL to the thumbnails folder. "no_photo_url" => "", // URL to the stub. . "auto_clear" => false, // clear skin cache X days. cache "rise_small" => true, // make the miniature (width/height) larger, so that the size is smaller than the specified size. "quality" => 90, / / type of miniatures that are created. available hosts, if possible, through whom." any" - whether hosts. "debug" => 0, // debug mode (for retailers). */ $opts["cache_folder"] = get_template_directory() .$opts["cache_folder_url"] = get_template_directory_uri() ."/cache"; $opts["no_stub"] = true; $opts["auto_clear"] = true; return $opts; ));

Umov's wit - a riddle about the plug-in or the right side in the description of topics.

//Viewing the first post image function first_post_image() ( global $post, $posts; $first_img = ""; ob_start(); ob_end_clean(); $output = preg_match_all("/ /i", $post->post_content, $matches); $first_img = $matches ; / enter a path to the image, as if it were a wildcard.) return $first_img;

The script is drawn before the image from the record, but if you don’t know how to do it, put the picture behind the lock. To enter the image for the mind, you are guilty of doing yoga, naming noimages.jpg and place it in a folder images. At the 11th row, indicate the path to the image.

1. Turn on the function of displaying the first picture in the topic

Thumbnail is included in all files, de records are displayed in the cycle - ce index.php, content.php, archive.php, category.php, single.php and etc.,
To connect, you need to insert the next code after the loop is defined, which looks something like this:

The code for viewing our function itself:

"title="(!LANG:(!LANG:!}!}"> "alt="(!LANG:(!LANG:!}!}" />

And the axis of the record needs to display a non-clickable picture. For whom is it necessary to single.php add code without asking

"alt="(!LANG:(!LANG:!}!}" />

Now your topic has no entries without thumbnails.

As I wrote more, now you don’t need to add a miniature to the record (don’t show them anyway), just insert a picture on the cob of the post. Persha after the rachunk, you will automatically become a miniature.

Still a small addition to the article.

If it’s necessary for you to show a miniature, but if it’s not, the first picture from the record, then it’s necessary to replace the term of vision, so that we can insert an offensive mind:

"alt="(!LANG:(!LANG:!}!}" />

Finally, add your own style classes and style them to CSS. So your miniatures will look the way you want.

On tsimu everything, dyakuyu for respect 🙂

© 2022 androidas.ru - All about Android