• Resolved mojamba

    (@mojamba)


    First, let me thank you for your excellent work. I have been looking for something like this for a while. I do have a few issues/questions/suggestions though.

    1. You set the pa-embed-player DIV style using the variable embedHeight (and embedWidth if stretch is set to false) BUT these are not actually set anywhere in your code. Adding the following line to your get_embed_player_html_code function would work:

    $embedHeight = $height;

    2. What is the purpose of the imageWidth and imageHeight variables? I ask because removing that from the image sources doesn’t seem to affect the output (and can be helpful – see #3). Also, many albums have both portrait and landscape photos so in theory each photo should have its dimensions assigned dynamically to be accurate but you just set them all to the same dimensions. IF there is some actual purpose for setting these dimensions, perhaps you should return them in the parse_photos function? For example, you could change that function’s return code to:
    return array_unique($m[0]);

    Then in the get_embed_player_html_code function you could add something like this:

    foreach ($photos as $photo) {
    	$photo = str_replace('"','',$photo);
    	$photo_src = substr($photo,0,strpos($photo,",")+1);
    	$photo_src = str_replace(',','',$photo_src);
    	$temp = substr($photo,strpos($photo,",")+1);
    	$imageWidth = substr($temp,0,strpos($temp,","));
    	$imageHeight = substr($temp,strpos($temp,",")+1);
    	....
    }

    It’s not efficient code so I am sure you can do better, but you get the idea at least I hope.

    3. Related to #2, the stretch feature doesn’t work for my album because it has a combination of portrait and landscape photos. I took a look at your pa-embed-player.min.js file and after a lot of digging and trial and error (I am not good with Javascript), I found that if I change your function bd(a) to the following I can get it to stretch the landscape photos and not stretch the portrait ones:

    function bd(a){if(a.b.src){var b=new y(0,0,a.b.naturalWidth,a.b.naturalHeight),c=kb(a.c());b=new y(0,0,b.width,b.height);var d=b.width/b.height;e=c.width/c.height;if(d<1){b.width=b.width;b.height=b.height;}else{e>d?(b.width=c.height*e,b.height=c.height):(b.width=c.width,b.height=c.width/d)};b.D=Math.round((c.width-b.width)/2);b.F=Math.round((c.height-b.height)/2);gb(a.b,new x(b.width,b.height));a=a.b;b=new r(b.D,b.F);b instanceof r?(c=b.a,b=b.b):(c=b,b=void 0);a.style.left=hb(c,!1);a.style.top=hb(b,!1)}}

    Note though that this only works if I edit the core PHP file to NOT set the width or height for any of the individual photos. So, I changed the following line:

    $src = sprintf('%s=w%d-h%d', $photo, $imageWidth, $imageHeight);

    to:

    $src = sprintf('%s', $photo);

    I would love to hear your thoughts on all of this. I have only tried with one album so far so while it seems to be working well I may be missing something that will cause problems in other circumstances.

    4. Do you know if there is any way to determine the cover photo for an album? If so, it would be good to make that the first photo displayed. I did a very quick online search and it seems like that isn’t possible but maybe I missed something that you know of?

    5. The plugin would be more user-friendly if you added a toolbar to the editor to quickly insert the relevant shortcode.

    6. I notice that your script generator misspells “description” (you spell it as “descrition” without a p). I see that is true for your JS file as well as the code generator on your publicalbum.org site.

    7. Is there a reason you don’t just bundle the JS file with the plugin so it can be a local server call instead of a call to the file location on your server?

Viewing 1 replies (of 1 total)
  • Plugin Author pavex

    (@pavex)

    Hi Jeff, thank you for your interest. I very much appreciate your approach.
    Here are my answers:

    1,2)
    “embedWidth” and “embedHeight” is a bug. The width and height attributes are correct.
    I fixed it to make the widget size correct.

    both attributes can be integer or “auto”. Auto is set to 100% of the parent component size. Just like a stretch, but it can be customized separately for both width and height.

    Jeff, for explanation, width and height are not the dimensions of the image. It’s only a widget widget.
    image-width and image-height are the maximum dimensions of the image.

    3) Stretch again applies only to the widget size. I recently replaced it by setting the width and height attributes to “auto”.

    Javascript of player is compiled to be small and fast, so it’s not readable.
    The mechanism of calculating the dimension of the image is more complex, however it is based on the dimension of the component and the actual dimension of the particular image.

    The “$src” variable contains the actual link to the Google Photos image. The url of the image also contains the dimension (maximum possible size). I briefly described this problem in my previous post on https://www.publicalbum.org/blog/embedding-google-photos-image

    4) There is, I will try to solve it.

    5) That’s a good idea. I have to see how to do it right.

    6) Thanks for warning, I will not forget to fix the next revision

    7) Now javascript is hosted on a single server. I want to change it and put it on some CDNs, but I have to deal with it gradually.

Viewing 1 replies (of 1 total)
  • The topic ‘Some questions and suggestion’ is closed to new replies.