FLEXIcontent / flexicontent-cck

Advanced content management for Joomla
http://www.flexicontent.org
82 stars 53 forks source link

How to resize images properly for gallery? #1075

Closed amityweb closed 8 months ago

amityweb commented 1 year ago

I need to fetch the custom fields for an entry type programmatically by PHP, so we have total control over the layout and everything.

When I fetch the galley field there is only the following in the database:

Array
(
    [originalname] => images/products/Product.png
    [existingname] => 
    [alt] => 
    [desc] => 
)

So its the original image, and no sizes for width / height.

Are the images resized or not, so we can display smaller than original as thumbnails and link to larger version in our custom code?

Is the data stored elsewhere in the database?

Should we be fetching image data via some other function built in? As stated, we are fetching our data via SQL from the database direct so we can have full control. We have written our own module to display a certain article type.

Thanks

micker commented 1 year ago

hello i didn't think we store image size in bdd a question : why we didn't use phpthumbs (include in flexicontent) ?

iamrobert commented 1 year ago

This is how we did it:

How to echo image width and height for raw image field value? https://www.flexicontent.org/forum/20-general-support/58067-how-to-echo-image-width-and-height-for-raw-image-field-value.html

gist: https://gist.github.com/iamrobert/39eb044f47a756d191ff062c58525a36

Other possibly relevant ideas:

amityweb commented 1 year ago

OK thanks. How do you get $item in the first place though?

I am not using universal module. I dont understand it as I cant find any info about how to use it online - if it even does what I want - which is to fetch all fields of all custom types so I can use in my custom template, or a single items fields for use on a single item page). So I have created my own module to fetch the content from the database, so I dont have access to an $item in my code.

Thanks

iamrobert commented 1 year ago

You can fetch all field values and lay them out using raw field values in your item.php template.

I didn't use UCM for the gallery - I used item.php as I want my gallery on the item page. Sorry this gist:

https://gist.github.com/iamrobert/b2f38a05d6800b6e9e92d4d660a1398e

To use custom code in FLEXIcontent, use raw values in the item.php template:

Here's a sample of a template for wheelchairs: https://gist.github.com/iamrobert/305d7ba33fcfe0fc4425d293e2244376

For this page: https://www.meritshealth.com/manual-wheelchairs/pediatric/l231-freego-kid

Note: this code is for J3 - yet to try J4.

micker commented 1 year ago

thanks @iamrobert for more explain ! question why you didn't create a galery template ? more reusuable not ?

iamrobert commented 1 year ago

I haven't explored creating gallery layouts, and am familiar with raw values.

I call the reusable field for the gallery in an item.php:

  // GALLERY BLOCK
  require_once( JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'templates' . DS . 'iamrobert' . DS . 'common-code' . DS . 'item-gallery.php' );

So - you can use it sitewide in any FC type. Plus, I can reuse iamrobert template files across client work.

With raw, you can have either youtube or images in the same gallery/slider: https://gist.github.com/iamrobert/e7a3e25ad4a5977741e79e50bc5b0881