Гость
04 Май 2013 10:12

Hello,

I am creating custom template for mocule "records" to show cobalt records in homepage and I noticed that if I insert there an image field to display the template (which is a records list template) automatically take the image thumbnail created for "list view" in the image field settings.

This may be a problem if I want to show a bigger image, because it results in a low quality image.

So... I don't how complicated this si technically, but it would be certainly useful to be able to choose which image use (thumbnail for list view, thumbnail for full view or original image)

Последние изменения: 27 Окт 2015


Sergey
Total posts: 13,748
06 Май 2013 01:52

It is parameter of the field. There are different parameters for list view and full article view. If in the module article list template you want thumbnail of different size than in section home article list template, then it is a problem. You will have to use special technique in your list template.

<?php

$image = new JRegistry($item->fields_by_key[$key]->value);

$url = CImgHelper::getThumb(JPATH_ROOT . DIRECTORY_SEPARATOR .$image->get('image'), 100, 100, 'image', $item->user_id, array(

        'mode' => $this->params->get('params.thumbs_list_mode', 1),

        'strache' => $this->params->get('params.thumbs_list_stretch', 0),

        'background' => $this->params->get('params.thumbs_list_bg', "#000000"),

        'quality' => $this->params->get('params.thumbs_list_quality', 80)));

if($url) {

  echo '<img src="'.$url.'" />';

}

?>

This is example code i did not test may be contain typos. But you have to understand idea. For more details how to get $key read knowledge article on mintjoomla (when we get it back)


Гость
06 Май 2013 03:28

Thank you Sergey, I will study your suggestion and try to apply it...


Гость
15 Май 2013 11:11

I dont' think I am enough skillful to apply your suggestion:S... let's see if others agree with me that it could be a nice feature

the reason it's simple: if you want to create a custom module with big images (think about roksprocket "showcase" style), right now it can't work, because it will get image thumbnails by default.

A quick solution would be to set image field to create big thumbnails and then force-resize them in records list with custom css

quick solution, but not advisable as you will end up with big images in your records list (even if you have froce-resized them, they are still big as for kb), and the page will load more slowly


Гость
15 Май 2013 11:24

maybe using smartslider module could solve this issue, I asked on a specific popst right now

http://support.mintjoomla.com/en/cobalt-8/questions/smart +slider+module%3A+which+images+uses+%28thumb+or+full%29%3F-3970.html#comment-16472

but even if ti could, i would still prefer to use the default records module and build my custom templates


Sergey
Total posts: 13,748
16 Май 2013 00:40

I also think that if you wrap image into dive with explicit width set, it will scale image accordingly.


Гость
16 Май 2013 03:52

I also think that if you wrap image into dive with explicit width set, it will scale image accordingly.

yes but we have 2 problems here

  1. the module use automatically image thumbs, thus even if I force-enlarge them the resolution will be bad

  2. if I generate bigger thumbs to fit my needs on teh records module, I will end up with big images in my records list (even if I have force-resize them to look smaller, they are still big as for kb), and the page will load more slowly


Sergey
Total posts: 13,748
17 Май 2013 00:56
  1. the module use automatically image thumbs, thus even if I force-enlarge them the resolution will be bad

Then make the size bigger than you use in template.

  1. the module use automatically image thumbs, thus even if I force-enlarge them the resolution will be bad

  2. if I generate bigger thumbs to fit my needs on teh records module, I will end up with big images in my records list (even if I have force-resize them to look smaller, they are still big as for kb), and the page will load more slowly

100 or 150 thumb widthd does not make really difference in size. And you can always set quality parameter. If you use 70 you make size dramatically slower but picture still looks good.


Гость
17 Май 2013 03:15

100 or 150 thumb widthd does not make really difference in size. And you can always set quality parameter. If you use 70 you make size dramatically slower but picture still looks good.

I know but here I am talking about bigger images, even 500 x 300 px

and beside that if developing responsive sites your modules will be responsive too, so you must use images which could be bigger for some screen-size

eg. maybe I have 4 moduels in a row for desktop screens

but only 2 modules in a row for i-pad, thus the images become bigger


Sergey
Total posts: 13,748
17 Май 2013 06:16

Anyway as far as I know responsive images are done only one way. The actual images little bug bigger than wrapper and wrapper adjust to screen and adjust image.


pepperstreet VIP
Total posts: 3,837
13 Июнь 2013 03:55

You will have to use special technique in your list template.

$image = new JRegistry($item->fields_by_key[$key]->value) > $url = CImgHelper::getThumb(JPATH_ROOT . DIRECTORY_SEPARATOR .$image->get('image'), 100, 100, 'image', $item->user_id, array( > 'mode' => $this->params->get('params.thumbs_list_mode', 1), > 'strache' => $this->params->get('params.thumbs_list_stretch', 0), > 'background' => $this->params->get('params.thumbs_list_bg', "#000000"), > 'quality' => $this->params->get('params.thumbs_list_quality', 80))); > if($url) { > echo ''; > } > ?>

AFAIK, you mentioned the new thumb handling here: - [6G] Picture field | image resize and thumbs

And the older Resources URL dependency and restriction for templates here: - records field template override | how to get and display image thumb ? (Hack/Fix)

Is your code-snippet the only way to call a specific thumbnail version?

Is it possible to generate a new, specific thumbnail size for a particular template?

Your older comments implied an easier, more flexible (and shorter) method... At least, I thought there is a shorter syntax.


Sergey
Total posts: 13,748
14 Июнь 2013 01:13

The example I gave with CImgHelper::getThumb() can generate thumbnail of any size.


Гость
18 Сен 2013 13:42

I have a problem with the images in the full articles being resized on screen but their source is the same file as the original uploaded large size. This is not too much of a problem on a desktop with decent internet connection, but on smaller mobile devices it causes a lot of lag obviously. Should I write a new post on this forum do you think?

Thanks.

D.


Jeff VIP
Total posts: 745
10 Окт 2015 03:08

Sergey,

could you please debug the code you have provided, because it doesn't work. :-(

It throws errors like

Parse error: syntax error, unexpected '>'

I have tried to debug it, but to no avail....


Sergey
Total posts: 13,748
11 Окт 2015 12:46

Updated my comment.


Jeff VIP
Total posts: 745
12 Окт 2015 09:17

With your updated comment:

Parse error: syntax error, unexpected T_VARIABLE in /home/mysite/public_html/components/com_cobalt/views/records/tmpl/default_list.php on line 95

Sergey
Total posts: 13,748
13 Окт 2015 20:46

Ther should be ; in the first line.


Jeff VIP
Total posts: 745
13 Окт 2015 23:49

Yes, I thought a ; was missing but now I get

Notice: Undefined property: CarticleHelper::$params in /home/mysite/public_html/components/com_cobalt/views/records/tmpl/default_list.php on line 96

Fatal error: Call to a member function get() on a non-object in /home/mysite/public_html/components/com_cobalt/views/records/tmpl/default_list.php on line 96

Im not sure wat is wrong here, because my code is an excact copy of yours:

<?php

$image = new JRegistry($item->fields_by_key['k2c9d87718ec1e094a79f407ea0c43192']->value);

$url = CImgHelper::getThumb(JPATH_ROOT . DIRECTORY_SEPARATOR .$image->get('image'), 100, 100, 'image', $item->user_id, array(

        'mode' => $this->params->get('params.thumbs_list_mode', 1),

        'strache' => $this->params->get('params.thumbs_list_stretch', 0),

        'background' => $this->params->get('params.thumbs_list_bg', "#000000"),

        'quality' => $this->params->get('params.thumbs_list_quality', 80)));

if($url) {

  echo '<img src="'.$url.'" />';

}

?>

Sergey
Total posts: 13,748
16 Окт 2015 13:00

Where do you use it? In field template or article template?


Jeff VIP
Total posts: 745
17 Окт 2015 01:06

Record list template


Sergey
Total posts: 13,748
19 Окт 2015 07:18

Now I get it.

<?php
$image = new JRegistry($item->fields_by_key['k2c9d87718ec1e094a79f407ea0c43192']->value);

$url = CImgHelper::getThumb(JPATH_ROOT . DIRECTORY_SEPARATOR .$image->get('image'), 100, 100, 'image', 
    $item->user_id, array(
        'mode' => 1,
        'strache' => 0,
        'background' => "#000000",
        'quality' => 80
    )
);

if($url) {
  echo '<img src="'.$url.'" />';
}
?>

Use custom parameters or add then to template parameters.

Работает на Cobalt