Advertisement:

Author Topic: What is Function of oc-content/uploads/x/xxx__preview.jpg / Bender Theme  (Read 1572 times)

mrtsoftware

  • Sr. Member
  • ****
  • Posts: 343
What is Function of oc-content/uploads/x/xxx__preview.jpg?
After submitting each item, into oploads it is created 3 type of images.
a) x.jpg
b) x_preview.jpg
c) x_thumbnail.jpg

When I remove " x_preview.jpg " files, appearence / view of pages were not affected...It seems that those images was not beeing used by webs...

If this is true, why Bender Theme is creating and unnecassary image files into /uploads/ folder?...This is increasing " disk usage " capacity on server...

I need advices from OSCLASS professionals...

mrtsoftware

  • Sr. Member
  • ****
  • Posts: 343
Can somebody help me about described subject given up?

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Try to add an item and not save it, ad only images to it. Then look if the image's file is called preview, before saving the item.

It showes something in ajax with preview, so I gues that's it.

Code: [Select]
.ajax_preview_img img

Liath

  • issues
  • Hero Member
  • *
  • Posts: 1346
  • </html> the end is always near
if i understand right, there is no use in standard themes and the creation of this file could be disabled here

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
I disabled that an the preview image is still there. I gues it's the preview from the upload images in item-post.php

Liath

  • issues
  • Hero Member
  • *
  • Posts: 1346
  • </html> the end is always near
oh... didn't read it right... i was thinking about *_original.jpg... sorry

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
But still. If there is the only place where it's being used, I'd suggest to modify it's dimensions in admin to something like 120x100 to use  as lithe space as posible.

Code: [Select]
.ajax_preview_img img {
    max-width: 120px;
    max-height: 120px;

Can someone confirm that there is the only place this preview image is used?
EDIT: in admin item edit the thumbnail is used, not the preview and in the rest of the site uses the thumbnail as well.

AND THANKS FOR THIS POST! :)

EDIT2.
But in that ajax preview the thumbnail is used also.....


« Last Edit: July 21, 2017, 11:59:24 am by marius-ciclistu »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Noone can tell for sure if that preview image is used or not?

teseo

  • Hero Member
  • *****
  • Posts: 6169
Hi,

Those are created in the core (oc-includes/osclass/ItemActions.php, public function uploadItemResources). I've seen a few themes making use of them, many others don't.

Regards
« Last Edit: July 22, 2017, 12:00:22 am by teseo »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Hi,

Those are created in the core (oc-includes/osclass/ItemActions.php, public function uploadItemResources). I've seen a few themes making use of them, many others don't.

Regards

Thank you Teseo. So in Bender's regard, those pictures can be made verry small so that they don't use space, but they are using inodes if they remain there, even if they are 1x1px small.

Would it be ok If we commend/remove this section?

Code: [Select]
                            // Create preview
                            $path = $tmpName."_preview";
                            $size = explode('x', osc_preview_dimensions());
                            ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path, $extension);

Then what will happen in the case of a regenerate images call from admin area? The preview images will not be renewed/modified, or there is another place where the preview images regeneration should be commented/removed from the code?
« Last Edit: July 22, 2017, 10:21:52 am by marius-ciclistu »

teseo

  • Hero Member
  • *****
  • Posts: 6169
There are two more lines on ItemActions.php below that block:

1.- osc_copy($tmpName.'_preview', $folder.$resourceId.'_preview.'.$extension);

2.- @unlink($tmpName."_preview");

Regarding regeneration of images, the process is different (oc-admin/controller/settings/media.php, case('images_post')).

Anyway, as said, previews might be required by some theme you'd want to install in the future, unless you're really tight on hard disk space I wouldn't go for these core modifications.

Regards

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Hi, you can see here what changes were required to actually do opposite of what you want (add 4th dimension), you can do the reverse to completely remove preview size, even from the admin side:

https://github.com/osclass/Osclass/pull/2080/files

Sure, you don't need to change admin settings etc. and you can modify preview helper function to return thumbnail instead (for compatibility with other themes and plugins).

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
dev101. Thank you.
I'll do those mods. I don't intend on changing bender theme whith another theme.

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
I made minimum changes so that the preview images are not being created in item actions events or regeneration, like this:

oc-includes/osclass/ItemActions.php:

Code: [Select]
                            // Create preview
                          //  $path = $tmpName."_preview";
                          //  $size = explode('x', osc_preview_dimensions());
                          //  ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path, $extension);
                          .
                          .
                           // osc_copy($tmpName.'_preview', $folder.$resourceId.'_preview.'.$extension);
                          .
                          .
                          // @unlink($tmpName."_preview");
                           

/oc-admin/controller/settings/media.php                         
Code: [Select]
                             // Create preview
                            // $path = osc_base_path().$resource['s_path'].$resource['pk_i_id'].'_preview.'.$resource['s_extension'];
                            // $size = explode('x', osc_preview_dimensions());
                            // ImageResizer::fromFile($path_normal)->resizeTo($size[0], $size[1])->saveToFile($path);

This should do it, or I must comment out also

oc-includes/osclass/utils.php

Code: [Select]
//@unlink(osc_base_path() . $resource['s_path'] .$resource['pk_i_id']."_preview.".$resource['s_extension']);?

I'm not interested in changing looks in admin. I'm only interested on preventing preview from being generated by user or admin (even if the dimensions etc remain in the db)

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Would also be nice if Admin was given choice in Settings regarding the generation of these images. It not only saves disk space but it will also save publishing time.

Other thought if this is theme depending, why not create a hook function that theme creators can use in case their theme is using these and in other case just don't.