Reputation: 11
I can send several photos like this:
group = []
for photo in photos2:
group.append(InputMediaPhoto(media=photo))
await message.answer_media_group(group, caption="Text123", text='Text123')
But caption and text don't work
I can also send a photo with text but only one
await message.answer_photo(photo=photo, caption=caption)
But I can't find how to send several photos with text I looked at the aiogram documentation but didn't find the answer to my question. How to do it?
aiogram 3.4.1
Upvotes: 1
Views: 1133
Reputation: 15
Try this one. Showing my example as reference:
from aiogram.utils.media_group import MediaGroupBuilder
@router.message(UploadPostAd.photos)
async def process_photos( message: Message, state: FSMContext):
# Process the photos here
if message.photo:
photo_ids = get_all_photo_ids(message) # Get all photo IDs
media_group = MediaGroupBuilder(caption="Media group caption")
for photo in photo_ids:
media_group.add_photo(type="photo", media=photo)
await message.answer_media_group(media=media_group.build())
await state.clear()
Upvotes: 0