Open-event-server: API & Placeholder images

Created on 16 Apr 2017  路  6Comments  路  Source: fossasia/open-event-server

In our new API-Centric approach, how do we handle placeholder images (based on category/topic/sub-topic) ?

  1. Does the API response for an event itself returns a placeholder image URL in the place of the background image if the background image doesn't exist ?
  2. Or, does the API response for an event return null for a non-existent image and we have a separate endpoint that provides all the placeholder images for each category and the frontend can use both to display the correct placeholder.

@mariobehling @aviaryan @SaptakS @shubham-padia @magdalenesuo your views ?

discussion question rest-api

Most helpful comment

Another alternative which I think is even better is in the API endpoint for events, we add an attribute placeholder_image which will contain the placeholder image depending on the category even if a background image is uploaded.

:+1: Since an event will only have one placeholder image, adding a field like this won't cause any overhead. And this certainly removes all ambiguities.

All 6 comments

Right now, in the /browse UI, placeholder images are not being differentiated from a real image at all. So I think we should have the API response return placeholder image if event's background is null.
But, after we move to the API centric approach, the edit event page may also use the same API for fetching existing event details. It won't be good to return placeholder images there.
If the endpoints for fetching /browse event information and fetching edit event's event information are different, we can easily do things in the backend to return placeholder images only where they are really needed.

In short, I am with returning placeholder images in the same API but this depends on how API endpoints are going to be defined.

I think fetching from a separate endpoint is a better option. That way things would be clean and separate and won't create confusion in terms of API results returned. If there is no background image, the API endpoint should return a null value instead of a placeholder value to avoid confusion at later stages of production. This also helps in avoiding any kind of interference with editing or updating event page. We can put the logic in the front-end only. I don't think it will make the js much heavy because it should be done by a single if check.

Another alternative which I think is even better is in the API endpoint for events, we add an attribute placeholder_image which will contain the placeholder image depending on the category even if a background image is uploaded. Then in front-end we will see that if background image present, use that, else use the placeholder_image attribute. This way the number of API requests will also stay minimal and there won't be any problem in readability as well. What do you think @niranjan94 @aviaryan @shubham-padia @magdalenesuo ?

Another alternative which I think is even better is in the API endpoint for events, we add an attribute placeholder_image which will contain the placeholder image depending on the category even if a background image is uploaded.

:+1: Since an event will only have one placeholder image, adding a field like this won't cause any overhead. And this certainly removes all ambiguities.

Another alternative which I think is even better is in the API endpoint for events, we add an attribute placeholder_image which will contain the placeholder image depending on the category even if a background image is uploaded.

@SaptakS I like the option suggested by you ... 馃憤

So should I work on this? @niranjan94

@aviaryan yes. You can proceed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SaptakS picture SaptakS  路  3Comments

Aju100 picture Aju100  路  4Comments

SaptakS picture SaptakS  路  3Comments

rafalkowalski picture rafalkowalski  路  3Comments

poush picture poush  路  3Comments