Skip to content

Commit

Permalink
Changed Events cover dimensions to 400x585
Browse files Browse the repository at this point in the history
Update EventUpcoming.tsx
  • Loading branch information
miksrv committed Feb 9, 2025
1 parent 832ec28 commit a2c67f8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const AstroStargazingForm: React.FC<AstroStargazingFormProps> = ({
</div>

<div className={styles.imageSection}>
{!!initialData?.cover && (
{!!initialData?.coverFileName && (
<Image
className={styles.image}
src={createLargePhotoUrl(initialData as ApiModel.Photo)}
Expand All @@ -170,7 +170,7 @@ const AstroStargazingForm: React.FC<AstroStargazingFormProps> = ({
</div>
<div style={{ marginTop: 15 }}>
<label>
{initialData?.cover
{initialData?.coverFileName
? 'Заменить обложку:'
: 'Загрузить обложку:'}
</label>
Expand Down
3 changes: 2 additions & 1 deletion client/components/event-upcoming/EventUpcoming.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { API, ApiModel, useAppSelector } from '@/api'
import { hosts } from '@/api/constants'
import { formatUTCDate, getTimeFromSec } from '@/functions/helpers'
import dayjs from 'dayjs'
import Image from 'next/image'
Expand Down Expand Up @@ -78,7 +79,7 @@ const EventUpcoming: React.FC<EventBookingFormProps> = () => {
<div className={styles.imageContainer}>
<Image
className={'stargazingImage'}
src={`${process.env.NEXT_PUBLIC_API_HOST}${data?.cover}`}
src={`${hosts.stargazing}${data?.id}/${data?.coverFileName}.${data?.coverFileExt}`}
alt={`Астровыезд: ${data?.title}`}
width={1024}
height={768}
Expand Down
4 changes: 2 additions & 2 deletions server/app/Controllers/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ public function create(): ResponseInterface {

$file->move($directoryPath, $fileFullName);

// Создаем превью 500x400 (сначала уменьшаем, потом обрезаем)
// Создаем превью 585 (сначала уменьшаем, потом обрезаем)
$mediumFileName = $fileName . '_preview.' . $fileExtension;
$image->withFile($directoryPath . '/' . $fileFullName)
->fit(500, 400, 'center') // Уменьшаем до 500x400, сохраняя пропорции
->fit(585, 400, 'center') // Уменьшаем до 585x400, сохраняя пропорции
->save($directoryPath . '/' . $mediumFileName);

$event->coverFileName = $fileName;
Expand Down

0 comments on commit a2c67f8

Please sign in to comment.