guy_van_bael

hi all, i use an uploadfield to upload an mp4 video. It uploads fine, but when i navigate to another page and upload a video there too and navigating back to my first page. On the first page it shows the filename from the second page. Reloading the page shows the correct file. Does anybody have a clue on how to fix this?

dorsetdigital

To answer the specific question, you'd almost certainly need to add an extension to do it I think

dorsetdigital

I looked (fairly briefly) at something similar before, and struggled to work out how to do it... so if you work it out, please share! In my situation I needed to go the other way so I could perform some masking operations on the image... due to time constraints I ended up having to just restrict the upload field to PNG files 😞

Nick

I know i would lose transparency, but have some narly photos uploaded as pngs

Nick

is there a way to change uploaded pngs to jpgs, or will I need to add an extension for that. Would that mess up anything changing the extension in regards to caching the output of any padding/fill etc operations?

Nick

@Tamara https://docs.silverstripe.org/en/4/developer_guides/model/versioning/#interacting-with-versioned-dataobjects

Tamara

@Nick Actually.. Cars is a has_many relation linked to a member. From Member I need to find all linked (and latest version of) cars. Normally, without versioning, just using $member->Cars() would be what I need, but that isn't returning all the cars that I need. So basically, is there a pretty way to query a has_many relationship with versioning?

Tamara

And I don't mind writing a custom query, but I just would like to prevent that as much as possible 🙂

Nick

You can do something like

  1. Versioned::get_by_stage('Car', Versioned::LIVE)->filter('MemberID', $member->id)->get()

or however the relation is setup

Tamara

Thanks! I was seriously overthinking it.

nightjarnz

@Tamara just fetch as normal, by default the records will be the latest versions.

nightjarnz

unless you mean regardless of published status AND you're in "live" mode, in which case you'll need to switch the query context first as @Nick has indicated :)

Tamara

I actually also need to retrieve archived versions, so that wasn't an option for me 🙂


Show less replies
Tamara

Hi all, I've got a DataObject (Cars), which has versioning on it. What's the best way to get all car objects (in which each record is only showing the latest version)?

alt

n/m, found the site was running the wrong php version

alt

any idea why I'm getting an error Uncaught Error: Class 'DOMDocument' not found?

nightjarnz

be careful not to set these on a production site ;)