modxcms / fred

The friendly front-end editor for visual, drag-and-drop content building in MODX CMS
https://fred.modx.com
MIT License
57 stars 25 forks source link

TVs aren't saved #492

Closed lottaar closed 5 months ago

lottaar commented 8 months ago

I followed the guide at https://modxcookbook.com/add-ons/fred/simple-image-tv.html to create a tv to be used in FRED. I can see the TV under Settings > Template Variables when editing the page in FRED. However, the image I select isn’t saved.

See https://community.modx.com/t/fred-and-collections/7266/5

MODX 3.0.4-pl Fred 2.1.4-pl PHP 8.2

lottaar commented 8 months ago

Did anyone get Collections working with Fred, including the use of images?

matdave commented 5 months ago

@lottaar I save TVs quite regularly and have a site that uses quite a few Image TVs. The basic set up is to select an Image TV, and add the properties fred: 1 and fred.type: image

lottaar commented 5 months ago

@matdave So you make the TV's input type Image, not Fred Dropzone? Would you be able to show an example of how you would display the image in a list of Collection items, using pdoPage, please? As a summary of the latests blog or news posts for example, if you know what I mean.

quaggax commented 5 months ago

@matdave I am having the same issue as @lottaar. I also followed the guide (same as your description) to set up TVs for selecting images from Fred and they won't save from Fred (only from the manager).

And according to a community post (also mentioned by lottaar) from @halftrainedharry there used to be a section that handled saving custom TVs from Fred. You removed this section in this commit: https://github.com/modxcms/fred/commit/033a24a1b6a8059e135dd653998278a8f5c923fc#diff-acc81f5f5f2fcb7ecd7ac1ec213790982c18139b2ccb855b1db4b64673644550L268-L281 And after downgrading my Fred install to the latest version before this commit (fred-2.1.2-pl), saving TVs instantly worked.

So are you sure this is not a bug? And if not could you please share detailed instructions on how to set up TVs for this current version of Fred?

matdave commented 5 months ago

@quaggax thanks for the additional information. I've found the issue you are running into and released a new package.

For clarification, Image TVs do NOT need to be freddropzone type. Only dropzone TVs need to be freddropzone type.

I've attached screenshots of the TV I have set up for testing:

image image image

lottaar commented 5 months ago

@matdave I've updated both Fred and Collections to the new versions you released and now the image TV is working as expected – awesome! Thank you!

lottaar commented 5 months ago

@matdave Is it possible to use pThumb in a Fred element to resize the TV image?

[[*fredImageTV]] returns the image path, but this just returns the full size image:

<img data-fred-name="bild" data-fred-attrs="alt" data-fred-target="tv_fredImageTV" class="d-block w-100 mb-4" src="[[pthumb? &input=[[*fredImageTV]]&options=w=900&h=900&q=85&zc=C]]">

The same piece of code in a chunk but with [[+tv.fredImageTV]] instead of [[*fredImageTV]] works fine.

In the error log it looks like it's to do with the Fred theme directory:

[2024-03-16 17:35:02] (ERROR @ /var/www/vhosts/domain.com/httpdocs/core/components/phpthumbof/model/phpthumbof.class.php : 156) [pThumb] Resource: 11 || Image: (none)
File not found: /var/www/vhosts/domain.com/httpdocs/[[++fred.theme.my-theme.theme_dir]]images/nameofimage.jpg  *** Skipping ***
lottaar commented 5 months ago

@matdave Is it possible to use pThumb in a Fred element to resize the TV image?

I managed to get pThumb to work by changing this:

<img data-fred-name="bild" data-fred-attrs="alt" data-fred-target="tv_fredImageTV" class="d-block w-100 mb-4" src="[[pthumb? &input=[[*fredImageTV]]&options=w=900&h={{ratio}}&q=85&zc={{zoomCrop}}]]">

To this:

                [[!pthumb? &input=`[[*fredImageTV]]` &toPlaceholder=`image` &options=`aoe=1&w=900&h=900&dpi=72&q=85&f=jpg&zc={{zoomCrop}}`]]
                <img  data-fred-attrs="alt" data-fred-target="tv_fredImageTV" class="d-block w-100 mb-4" src="[[+image]]" alt="{{alt}}">

But then I get another issue, as I can't select the image under Settings > Template Variables in Fred. See https://github.com/modxcms/fred/issues/494#issue-2192264879